no-cache javascript

I

ICode

Hi, all,

I am currently updating links for a site almost daily. I have set the
META tags to allow for no caching so that as soon as the site is
updated on the server, the new changes can be seen by the people
logging onto the site.

But I have a problem when it comes to the javascript files associated
with the .asp files. It seems as if the javacsript files are cached,
even though the page page calling it is not.

So, the viewer sees my changes to the site, but has to refresh the
page each time the person wants to view the new javascript links.

Any ideas on what I might be able to do?

Thanks.
 
E

Evertjan.

ICode wrote on 16 jun 2004 in comp.lang.javascript:
I am currently updating links for a site almost daily. I have set the
META tags to allow for no caching so that as soon as the site is
updated on the server, the new changes can be seen by the people
logging onto the site.

But I have a problem when it comes to the javascript files associated
with the .asp files. It seems as if the javacsript files are cached,
even though the page page calling it is not.

So, the viewer sees my changes to the site, but has to refresh the
page each time the person wants to view the new javascript links.

Any ideas on what I might be able to do?

<script type="text/javascript"
src="/lib/mylib.js? said:
</script>

not tested.
 
G

Grant Wagner

Evertjan. said:
ICode wrote on 16 jun 2004 in comp.lang.javascript:


<script type="text/javascript"


not tested.

It works fine for refreshing external Javascript files. But unless mylib.js
is being dynamically generated every page load, it's sort of a waste of
bandwidth to re-retrieve it each time it's needed (it also defeats the point
of using an external file in the first place).

Personally I use something like:

<script type="text/javascript" src="file.js?v=200406171440"></script>

Then when I change the ASP page in a way that requires an update to the
Javascript, I just change the [v]ersion. If you use the .js file in many
places, then use server-side includes or a function call to embed the
<script> tag on each page, all with the same [v]ersion.

Even if the .js file changes intermitantly, it would be worthwhile to
implement some sort of versioning system that only changed the stuff after
"yourfile.js" when it was actually necessary.

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top