Simple Apache Expires Setup via .htaccess

If you’ve used Google Page Speed then you’ve probably seen “Leverage browser caching” as one of the items on the Medium Priority list. And it’s a real simple fix if you’re running Apache. Just create or edit your .htaccess file for the site you want to enable it on and input the following.

<IfModule mod_expires.c>
    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"
</IfModule>

And Viola, you’re now telling Web Browsers not to grab Images/CSS or Javascript unless otherwise required.


Did you like this article?


0 Shares:
You May Also Like

Apple Releases iPhone Firmware 2.1 and iTunes 8

Apple has just released iTunes 8 and the iTouch and iPhone firmware 2.1! You will need to download iTunes 8 in order to get the new firmware. And unfortunately it looks as though iTunes 8 has blocked the Pwnge tool. However the iphone-dev team knows about this and will have a patch http://blog.iphone-dev.org/post/49689803/countermeasures Enjoy!
Read More