1

I'm AdSense publisher and I need to improve the page speed score for my site. It already gets 90/100 for speed and 100/100 for User Experience, however Google AdSense code is preventing it from getting the full 100/100

This is the error:

Leverage browser caching for the following cacheable resources:
http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js (60 minutes)
http://pagead2.googlesyndication.com/pagead/osd.js (60 minutes)

My questions:

  1. Can I cache adsbygoogle.js and osd.js for longer using .htaccess?
  2. will it effect my AdSense revenue? I won't sacrifice my revenue for higher score.
  3. How much longer should I cache it? 1 day? 1 week?

Google encourages me to improve my web page speed, but it seems like the only way to achieve 100/100 is to get rid of Google AdSense.

1

adsbygoogle.js and osd.js are third party JavaScript files. Your server isn't the one that sends them to users, so you have no control over their caching. .htaccess will be of no help in this situation.

The page speed recommendations are just that: recommendations. They are not hard and fast rules. There are times that you want to break the rules. In this case, AdSense doesn't allow those files to be cached because doing so might show the same ads to the same user. AdSense wants control over exactly which ads a user sees for each pageview.

So you are correct. If you want a perfect page speed score, you have to ditch AdSense.

| improve this answer | |
  • There's a hardcore way to override that: You can indeed save these JS locally or on CDN and serve the JS with a modfied cache header. :) Dirty, but works out for pages that need every little piece of SEO optimization. – Sliq Dec 24 '14 at 17:23
  • Copyng those files and hosting them locally is not a good idea. It is a copyright violation unless you get permission to do so. It could break functionality -- for example those files may be customized per visitor or for different browsers. The third parties won't be able to make updates to those files so it may break things in the future. – Stephen Ostermiller Dec 15 '17 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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