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

Apples iPhone Firmware 2.0.2 Causes More Issues Than It Fixes

I just saw this article on Slashdot... Slashdot | Apple's IPhone 3G Firmware Update Bombs Yahoo posted the news article... Apple's iPhone 3G Firmware Update Bombs (NewsFactor) by NewsFactor: Yahoo! Tech Both articles comment on the 2.0.1 firmware. However if you read the original article, it speaks about the new firmware which is 2.0.2 and was released on the 18th. NewsFactor Network | Apple Reportedly Plans Another Fix for the iPhone Either way, I don't have problems with my phone aside from MobileChat crashing and other Applications as well.
Read More