Leverage browser caching on wordpress with serverpilot

November 9, 2014 3k views

I ran into issue when testing speed of a site. The issue is with Leverage browser caching. I setup my server has a 1GB Ram 30GB SSD Disk New York 3 Ubuntu 14.04 x64 and using server pilot. The site seems to run great except for this issue. Any suggestion on how to resolve the leverage issues?

2 Answers

Presumably, you are referring to the Leverage Browser Caching rule from Google's PageSpeed Insights.

If your site is using Apache, one way to allow browsers to cache your content is by setting Expires headers on your static files. First run sudo a2enmod expires Then add the following to your VirtualHost or .htacccess file:

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 2 days"

Finally, restart Apache with sudo service apache2 restart Your site will no longer display that warning in Google's PageSpeed Insights.

I'm busy with same stuff right now...
Serverpilot installs a custom apache version and common apache tools doesn't work.

I got this snippet from a friend and the headers are looking fine, but I'm still getting these warning from Google insights :(

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType application/javascript "access plus 1 year"
Have another answer? Share your knowledge.