I have a wordpress website with a custom theme that I created myself. Currently, I am working on suggestions from "Google PageSpeed Insights", to improve user-experience on my website.
PageSpeed is suggesting "Leverage Browser Caching". Below are the results:
**Leverage browser caching** Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network. 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) http:.//www.google.com/…callback%22%3A%22__gcse.sacb%22%7D%5D%7D (60 minutes)
So, basically, it is suggesting me to set "expiry-time" for cache of the Adsense scripts to 60 minutes.
I tried to check the caching status of my website via REDbot. Below are the results:
General
The server's clock is correct.
Content Negotiation
The resource doesn't send Vary consistently.
Content negotiation for gzip compression is supported, saving 72%.
Caching
This response allows all caches to store it.
This response allows a cache to assign its own freshness lifetime.
My understanding of the results is that my website allows caching and that it allows a cache to assign its own refresh time. I am not using any HTML "meta" tags for caching so basically, my server is configured this way.
Now my question is: how would I manually set the "expitry-time" for the scripts to 60 minutes. I know how to use ".htaccess" file to set caching duration for various file types ((using FilesMatch)). But, presumably, this method works for File types, not individual scripts within ".php" files. So, how can I change the caching expiry-time of adsense scripts?
((This is my first stackoverflow question, so if there is any mistake or deficiency, please point it out for me.. Thanks))
UPDATE:
After the answer from "Andrew", I added the following to my .htaccess file.
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 hour"
ExpiresByType image/jpeg "access plus 1 hour"
ExpiresByType image/gif "access plus 1 hour"
ExpiresByType image/png "access plus 1 hour"
ExpiresByType text/css "access plus 1 hour"
ExpiresByType text/html "access plus 1 hour"
ExpiresByType text/x-javascript "access plus 1 hour"
ExpiresByType image/x-icon "access plus 1 hour"
ExpiresDefault "access plus 1 hour"
</IfModule>
## EXPIRES CACHING ##
But it gave me strange results. Pagespeed now decreased my score and has the following suggestions now:
Leverage browser caching Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network. 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) http.://www.google.com/…callback%22%3A%22__gcse.sacb%22%7D%5D%7D (60 minutes) http.://www.mananatomy.com/…heme/images/mananatomy_logo_modified.jpg (60 minutes) http.://www.mananatomy.com/…mages/mananatomy_logo_modified_small.jpg (60 minutes) http.://www.mananatomy.com/…s/mananatomy-theme/images/sidebar_bg.jpg (60 minutes) http.://www.mananatomy.com/…ontent/themes/mananatomy-theme/style.css (60 minutes) http.://www.mananatomy.com/…t/uploads/2010/12/basic-anatomy-logo.jpg (60 minutes) http.://www.mananatomy.com/…nt/uploads/2010/12/body-systems-logo.jpg (60 minutes) http.://www.mananatomy.com/…ntent/uploads/2010/12/histology-logo.jpg (60 minutes)
So it got even more confusing. Any help ???