How to Leverage Browser Caching via .htaccess

Share:
By using this code, our main static files (images, CSS, PDF’s, JS, etc.) will be cached in order to produce faster loading times in the future.

Leverage Browser Caching


 # enable expirations  
 <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|txt|html|x-html|php|css|xml|js|woff|ttf|svg|eot)(\.gz)?$">  
 <IfModule mod_expires.c>  
     ExpiresActive On  
 </IfModule>  
 <IfModule mod_headers.c>  
 # expire GIF images after a month in the client's cache  
 ExpiresByType image/gif A2592000  
 # HTML documents are good for a week from the  
 # time they were changed  
 ExpiresByType text/html M604800  
 </IfModule>  
 </FilesMatch>  

No comments

Ads