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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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"
</IfModule>
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>
<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"
</IfModule>
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.