Skip to content

Instantly share code, notes, and snippets.

@jonathanstark
Created September 25, 2015 18:10
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 jonathanstark/163ac0d0891aa9d6d85c to your computer and use it in GitHub Desktop.
Save jonathanstark/163ac0d0891aa9d6d85c to your computer and use it in GitHub Desktop.
Caching stuff for Apache .htaccess file
##### CACHING STUFF #####
# 1 YEAR
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 3 HOUR
<FilesMatch "\.(txt|xml|js|css)$">
Header set Cache-Control "max-age=10800"
</FilesMatch>
# NEVER CACHE - notice the extra directives
<FilesMatch "\.(html|htm|php|cgi|pl)$">
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</FilesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment