LEVERAGE BROWSER CACHING

Set cache header for front end files. I usually add this codeĀ once the website is online.


Author: Anonymous
Added: Monday, 14 Jul, 2014
Category: htaccess
Tags: Apache

Code

## LEVERAGE BROWSER CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 week"
ExpiresByType image/jpeg "access 1 week"
ExpiresByType image/gif "access 1 week"
ExpiresByType image/png "access 1 week"
ExpiresDefault "access 7 days"
</IfModule>
 
## Fonts caching for a year
<FilesMatch "\.(eot|svg|ttf|woff)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
 
## Cache Icon, PDF and Flash movie for a year
<FilesMatch "\.(ico|pdf|flv|swf)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
 
## Cache CSS and JS for 1 week
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=604800, proxy-revalidate"
</FilesMatch>
 
## LEVERAGE BROWSER CACHING ##

Comments