0

I need to write a Greasemonkey script which will prevent Firefox from caching certain pages. Is that possible at all?

I know it's possible to reload a page with

window.location.reload(true) 

-- but the script won't even run when page is loaded from cache, and even if it runs, how do I know that page is loaded from cache and not from URL?

I know that adding

<meta http-equiv="Cache-control" content="No-Cache"> 

to HTML of the page would do the trick, but is only parsed at the initial load, and adding it thru GM does not work...

So, how do I achieve this? Is it possible with GM at all?

2
  • Re: the script won't even run when page is loaded from cache. Then cache is not your issue. Most likely the page is AJAX driven. Scripts run regardless of whether the page was loaded from cache. Commented Jun 3, 2014 at 0:09
  • Well, If I had the script which could affect 'meta' tags before they are interpreted by the browser, then I would always be able force refresh the page I need, making it run the script, and set up all the metatags needed to prevent browser from caching, right? Commented Jun 3, 2014 at 12:15

1 Answer 1

1

You can't prevent the page from being cached, but you may be able to do the next best thing and add a cache-buster.

http://www.adopsinsider.com/ad-ops-basics/what-is-a-cache-buster-and-how-does-it-work/

function() { // var url = window.location.href; var url = "http://z.invalid?cachebuster=10"; var bits = url.split('?'); var newUrl = bits[0]; newUrl += "?cachebuster=" + Math.random()*10000000000000000; window.location.href = newUrl; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.