Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# NOTE
# .htaccess files are an overhead, this logic should be in your webserver config if poss
# Changing webserver (lighttpd, nginx) will probably improve site response times more than these tweaks
# Here goes any other rules you, your framework, or whatever app you're using needs
FileETag All
# if it's not a php file (and it's a real file, in the webroot)
<FilesMatch "\.(?!php).*$">
# CHOICE EITHER
# 1) These settings will ensure there are no stale cache files
<IfModule mod_headers.c>
Header set Cache-Control "max-age=864000, public, must-revalidate"
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 year"
</IfModule>
# 2) These settings will eliminate any validation requests -
# This will increase performance but is only appropriate if you're fingerprinting files
# I.e. the file doesn't or very rarely changes, and if you change it - you change the filename
# FileETag None
# Header unset ETag
# Header unset Last-Modified
# CHOICE END
</FilesMatch>
# Unless it's a static-cached html file
<FilesMatch "\.html$">
<IfModule mod_headers.c>
Header set Cache-Control "must-revalidate"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</IfModule>
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
</FilesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment