Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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

<?php
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
1  
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? –  Tino 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

1 Answer 1

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
    
Don't forget to approve the answer if you like it, thanks! –  JVerstry Aug 25 at 17:39

Your Answer

 
discard

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.