Skip to content

Instantly share code, notes, and snippets.

@tilap
Last active August 29, 2015 14:15
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 tilap/e3b618d153c8f405e230 to your computer and use it in GitHub Desktop.
Save tilap/e3b618d153c8f405e230 to your computer and use it in GitHub Desktop.
Expire and header mods Apache rules to improve cache on statics files. Apply 864000 seconds cache on images, icons, html, javascript and css files. To insert in apache Virtualhost.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 180 seconds"
AddType image/x-icon .ico
AddType text/css .less
ExpiresByType image/jpg "access plus 864000 seconds"
ExpiresByType image/jpeg "access plus 864000 seconds"
ExpiresByType image/png "access plus 864000 seconds"
ExpiresByType image/gif "access plus 864000 seconds"
ExpiresByType image/ico "access plus 864000 seconds"
ExpiresByType image/icon "access plus 864000 seconds"
ExpiresByType image/x-icon "access plus 864000 seconds"
ExpiresByType text/css "access plus 864000 seconds"
ExpiresByType text/javascript "access plus 864000 seconds"
ExpiresByType text/html "access plus 60 seconds"
ExpiresByType application/xhtml+xml "access plus 864000 seconds"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\\.(ico|jpe?g|png|gif|swf|css|gz)$">
Header set Cache-Control "max-age=864000, public"
</FilesMatch>
<FilesMatch "\\.(js)$">
Header set Cache-Control "max-age=2592000, private"
</FilesMatch>
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment