[Greasemonkey] Beginner GM_xmlhttpRequest caching question

Adam Judson adamsplugins at gmail.com
Sat Feb 4 10:23:41 EST 2006


Requests made using XMLHttpRequest are not cached in the browser, there is
special code which adds an inhibit cache flag to the request.

I know this because I had to do all sorts of tricky things to make
"view source" work
for my extension (tamperdata).

Adam

- no idea about what the servers doing though.

On 04/02/06, Aaron Boodman <zboogs at gmail.com> wrote:
> 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
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>


More information about the Greasemonkey mailing list