• Content
  • Comments (0)
  • Related articles

Optimize the Leverage browser caching Wednesday, 13 February 2013

When checking an website performance via Google Developers Tool, in some cases it returns an warning under Leverage browser caching. The following solution was tested on WordPress platform but should work on any website. The funny thing in this test/tools is that Google itself does not always follow protocol implemented by this test, see the results bellow.

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.
Learn more

Suggestions for this page

The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:


One way to overcome this is by modifying the .htaccess file, found in the /public_html/ root with following content:

# BEGIN Browser caching
# Turn on Expires and set default expires to 3 days
ExpiresActive On
ExpiresDefault A259200

# Set up caching on media files for 1 month
<filesMatch ".(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
  ExpiresDefault A2419200
  Header append Cache-Control "public"

# Set up 7 days caching on commonly updated files
<filesMatch ".(xml|txt|html|js|css)$">
  ExpiresDefault A604800
  Header append Cache-Control "private, must-revalidate"

# Force no caching for dynamic files
<filesMatch ".(php|cgi|pl|htm)$">
  ExpiresDefault A0
  Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
  Header set Pragma "no-cache"

# END Browser caching




Post a Comment

Your email is never published nor shared. Required fields are marked *