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

Microsoft changes their mind about allowing virtulization of Vista Home and Premium

No virtualization for home or premium? Is a ploy to take more money back from the consumer to buy the "super-duper-more-expensive" version so that you can do virtualization?
Microsoft ditches about-face on virtualization restrictions at 11th hour -

Microsoft this week was about to relent and allow the (legal) virtualization of Windows Vista Home Premium and Home Basic. Then the company pulled the plug on the announcement, but there are signs that a change is still possible.

Read More...

[Ars Technica]
Read More