[thelist] Reload and Bypass Cache

Stéphane Deschamps (nota-bene.org) stephane.deschamps at gmail.com
Thu Mar 24 05:59:39 CST 2005


On Mon, 21 Mar 2005 11:25:51 -0500, Hershel Robinson
<hershelr at netvision.net.il> wrote:
> I am looking for a method in JavaScript for Win IE6 to reload a page and
> bypass cached files. The normal user method to do this is Shift-Refresh. The
> only JS method I have come up with is this:
> 
> history.go(0)
> 
> which is purported to be the most effective method, albeit not guaranteed to
> always bypass caches.
> 
> Any other ideas?

Hi Hershel,

What I do usually is append a string to the current URL, so as to
bypass even the browser's own cache.

Something like that:
(watch out for any wrap)
function refresh() {
    now = new Date();
    str = now.getTime().toString();
    l = this.location.toString();
    this.location.href= l + ((l.indexOf("?")==-1)? "?" : "&") + str;
}

Call refresh() whenever needed.

Actually it's not that good a method, because if you call refresh()
from a refreshed page, you get another append on the first, but it can
be a good basis for what you're trying to do... and in my experience
you're sure to have a good refresh.

HTH
-- 
Stephane Deschamps
personal: http://nota-bene.org/
org: http://evolt.org/
french org: http://pompage.net/


More information about the thelist mailing list