Issue
- How to enable Leverage Browser Caching for my website or server.
- How to set expiry time for my website contents.
- How to enabled Leverage Browser Caching for my wordpress / joomla / drupal / django websites.
- Webpage performance test sites like gtmetrix.com and webpagetest.org reports that Leverage Browser Caching is not enabled on my website.
Environment
- Website running on Apache web server
- Website running on cPanel shared hosting
Resolution
Add the following entry in your .htaccess file.
# Leverage Browser Caching START
ExpiresActive On
ExpiresByType image/jpg "access 7 days"
ExpiresByType image/jpeg "access 7 days"
ExpiresByType image/gif "access 7 days"
ExpiresByType image/png "access 7 days"
ExpiresByType text/css "access 7 days"
ExpiresByType text/html "access 2 days"
ExpiresByType application/pdf "access 7 days"
ExpiresByType text/x-javascript "access 7 days"
ExpiresByType application/x-shockwave-flash "access 7 days"
ExpiresByType image/x-icon "access 7 days"
ExpiresDefault "access 7 days"
# Leverage Browser Caching END Now go to gtmetrix.com and test your site. You should see 100% gzip compression.



