APACHE EXPIRES HEADERS WITH MOD EXPIRES

When visiting some website, the website will cache in your browser. This cache can be controlled by configuring yourCache-Control HTTP headers for your website This is done by adding mod_expires in the .htaccess file of your server.

If you don't set your Cache-Control for the HTTP headers, then, you will have a longer wait times when visiting your website. Each time your website is accessed without Cache-Control, your website has to make a request to the server for each image, javascript file, CSS file, and so forth to load.

Browser caching is good because it allows your web resources to be stored in the browser for faster page load time. This makes your site faster to surf on the web. To remove the cache from your browser, your browser cache needs to be cleared. The following sections will explain the basics of setting up the Apache Module mod_expires in your .htaccess file

Quick example of how to set default expires headers. This will help prevent browsers from re-downloading the same images more than once and therefore reduce the load on your image server.

Put this in your .htaccess file:
   ExpiresActive on  
   ExpiresByType image/gif "access plus 1 years"  
   ExpiresByType image/jpeg "access plus 1 years"  
   ExpiresByType image/png "access plus 1 years"   
   ExpiresByType text/css "access plus 1 years"  
   ExpiresByType text/js "access plus 1 years"  
   ExpiresByType text/javascript "access plus 1 years"  
   ExpiresByType application/javascript "access plus 1 years"  
   ExpiresByType application/x-javascript "access plus 1 years"   
   #ExpiresDefault "access plus 1 days"  


Have a good day!
Previous
Next Post »