Skip to content

Instantly share code, notes, and snippets.

@dontfreakout
Created April 6, 2016 21:51
Show Gist options
  • Save dontfreakout/41f4f8a5ccfb70c37b3bdc2f875e2fe2 to your computer and use it in GitHub Desktop.
Save dontfreakout/41f4f8a5ccfb70c37b3bdc2f875e2fe2 to your computer and use it in GitHub Desktop.
Htaccess Leverage Browser Caching
# Leverage Browser 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 image/svg+xml "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 hour"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/json "access plus 0 seconds"
ExpiresDefault "access 1 month"
</IfModule>
<IfModule mod_headers.c>
<filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf|svg)$">
Header set Cache-Control "max-age=2678400, public"
</filesmatch>
<filesmatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
<filesmatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</filesmatch>
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=2678400, private"
</filesmatch>
<filesmatch "\.(json)$">
Header set Cache-Control "no-cache"
</filesmatch>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment