Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Changing and reloading included .js files

Reply
Thread Tools

Changing and reloading included .js files

 
 
jodleren
Guest
Posts: n/a
 
      03-20-2008
Hi

I just came a problem with JS on a site - I updated my .js file for
the site, it is included as follows:

<link rel="stylesheet" href="whatever.css" type="text/css">
<script type="text/javascript" src="whatever.js"></script>

Problem: IE does not automatically reload the .js file (nor .css) but
uses a cached version - which caused the site to fail this morning.
I know users have to press F5 to reload, but is there a way to _force_
reload, so¨my (stupid) users do not have too?

WBR
Sonnich
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      03-20-2008
jodleren wrote:

> I just came a problem with JS on a site - I updated my .js file for
> the site, it is included as follows:
>
> *<link rel="stylesheet" href="whatever.css" type="text/css">
> *<script type="text/javascript" src="whatever.js"></script>
>
> Problem: IE does not automatically reload the .js file (nor .css) but
> uses a cached version - which caused the site to fail this morning.
> I know users have to press F5 to reload, but is there a way to _force_
> reload, so¨my (stupid) users do not have too?


You could make the requested URI unique:

'whatever.js?' + (new Date()).getTime();

Or, if you're under Apache, you could try to manipulate the headers in
order to avoid caching:

http://httpd.apache.org/docs/2.0/mod/mod_expires.html

Hope this helps,

--
Bart
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      03-20-2008
jodleren wrote:
> I just came a problem with JS on a site - I updated my .js file for
> the site, it is included as follows:
>
> <link rel="stylesheet" href="whatever.css" type="text/css">


Your stylesheet is irrelevant here. A stylesheet is not a script (at least
not in non-NN4).

> <script type="text/javascript" src="whatever.js"></script>
>
> Problem: IE does not automatically reload the .js file (nor .css) but
> uses a cached version - which caused the site to fail this morning.
> I know users have to press F5 to reload, but is there a way to _force_
> reload, so¨my (stupid) users do not have too?


http://www.mnot.net/cache_docs/

Despite statements to the contrary, this works also with non-Apache servers.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
reloading .rb files / reparsing? dc Ruby 1 02-03-2007 04:35 PM
Changing Location Bar Contents without Reloading Howard Charles Javascript 0 01-24-2006 11:16 PM
changing the URL without reloading the page iwearwatches Javascript 5 09-21-2005 11:00 AM
Dynamic Class Reloading and Class File Update and Lock/Synchronization? Shailender Bathula Java 1 02-17-2005 09:08 AM
Header files included in header files John Smith C Programming 18 07-24-2004 04:55 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57