[Greasemonkey] Beginner GM_xmlhttpRequest caching question

Aaron Boodman zboogs at gmail.com
Sat Feb 4 02:19:23 EST 2006


On 2/4/06, Jonas Lundberg <my.name.is.hans at gmail.com> wrote:
> However, the *next* time I try to load a page that I just read through
> GM_xmlhttpRequest, the server returns the message <-- Cachehit -->. I
> guess that means the server assumes that the page is cached in the
> browser. Does anybody know how to get the page from the browser cache
> in that case?

I have no idea what that means. If the server wanted the the browser
to use what was in it's cache, I think it is supposed to respond with
HTTP 304 Not Modified (but IANAL). In that case, I believe FF would do
the right thing and return the cached content to you.

I wonder what would happen if you loaded one of the pages in FF, then
press refresh (not ctrl+refresh, just simple refresh). Do you get this
same message in your browser?

In any case, you can probably work around the issue by adding a random
string to the querystring or hash. Try something like this:

var url = originalUrl + (originalUrl.indexOf("?") > -1 ? "&" : "?") +
new Date().getTime();

or:

var url = originalUrl + "#" + new Date().getTime();

And then use that URL instead with GM_xmlhttpRequest. This might trick
the server into thinking you're requesting a different page.

- a


More information about the Greasemonkey mailing list