Skip to content

Instantly share code, notes, and snippets.

@EastSideCode
Last active February 5, 2018 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EastSideCode/0b4b8ec4c8d5d2b94e8c718c514e14f1 to your computer and use it in GitHub Desktop.
Save EastSideCode/0b4b8ec4c8d5d2b94e8c718c514e14f1 to your computer and use it in GitHub Desktop.
Leverage browser caching with .htaccess
## EXPIRES CACHING ##
# In apache, be sure to enable mod_headers and mod_expires
# sudo a2enmod headers
# sudo a2enmod expires
#
# Then restart apache
# service apache2 restart
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
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"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment