Skip to content

Instantly share code, notes, and snippets.

@peterwegren
Last active January 26, 2017 18:55
Show Gist options
  • Save peterwegren/44d02db331f2b2a7821a2344ab116c06 to your computer and use it in GitHub Desktop.
Save peterwegren/44d02db331f2b2a7821a2344ab116c06 to your computer and use it in GitHub Desktop.
Apache .htaccess browser caching settings.
## EXPIRES CACHING ##
<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 text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
## Cache-Control ##
# One year for image files
<filesMatch ".(jpg|jpeg|png|gif|ico)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
# One month for css and js
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>
## Cache-Control ##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment