[Javascript] Cache prevention with a changing query string?

Rodney Myers rodney at aflyingstart.net
Wed Jul 4 04:04:28 CDT 2001


In comp.lang.javascript someone recommended a link like this to prevent
a page coming from cache.

The idea is to add a different query string every time the page is
called:

<p><a href="test.html"
  onclick="document.location.href='test.html?cCache=' + (new
 Date()).valueOf();return false;">link text</a></p>


Being a lazy person who prefers not to write things twice if once will
do, I would prefer to write something like:

<p><a href="test.html"
  onclick="document.location.href=this.href+'?cCache=' + (new
 Date()).valueOf();return false;">link text using this.href</a></p>

 Where this.href removes the need to repeat the page name.

 The contributor, whose original message I do not have, commented that
having a normal href property in the link would enable the link to work
with javacript off (though without the cache bypassing bonus).

 Does anyone have positive or negative expereince of working with such
anti cache devices?

 Assuming it does work, I would then work on adapting the date related
query string so that (for example) the query string would not change
during a day, so the page could come from cache during any given
shopping session.


 TIA

 Rodney

--
Shop at ssistant Add-ons and Developer Workshops
http://www.aflyingstart.net/addons/

Enquiries regarding Shop at ssistant Classic training :
Call 01256 880770

Rodney Myers
Based in Oxford, England
Technical Director, Shop at ssistant eCommerce Solutions






More information about the Javascript mailing list