Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a page where I need to avoid JavaScript caching by browser. I've added this header:

header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
header('Expires: 0');

After this, browsers didn't cache more JavaScript sorting out the issue, but in the same time I noticed a drop in Google AdSense RPM.

Then I removed the added code and now Google AdSense RPM is reaching again a good value.

So, how could I avoid JavaScript caching without meddle with AdSense performance?

share|improve this question
In normal circumstances caching of your JavaScript files should not make any difference in AdSense usage. Do you use some custom AdSense wrappers or Google defaults? Are you sure that all your js code is initializing properly when you activate caching? – user12733 Nov 4 '13 at 15:23
Are you adding these headers to all files, or just the javascript files? – Stephen Ostermiller Nov 17 '13 at 19:27

Rather than trying to avoid Javascript caching, which is not very natural, I would try to fetch the 'variable data part' as a JSON using Ajax for example.

If Google can't be sure what your Javascript is all about (since you configuration means it can change each time), then it cannot trust it. Hence, rather than taking a RPM risk, it will take the safe road and give the RPM to other sites it can trust.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.