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

Guide to upgrading Drupal using SSH Commands

A well written guide on how to upgrade Drupal using SSH commands
This guide is meant to augment the official Upgrade guide. Please read the official upgrade steps in UPGRADE.txt as well as in the Drupal.org Dcoumentation thoroughly to ensure that you understand every aspect of the upgrade process. This guide is for more advanced users with SSH experience.
Read More