Skip to content

Instantly share code, notes, and snippets.

@RhythmShahriar
Last active December 24, 2015 19:19
Show Gist options
  • Save RhythmShahriar/6849429 to your computer and use it in GitHub Desktop.
Save RhythmShahriar/6849429 to your computer and use it in GitHub Desktop.
# @package Caching Tutorail
# @link http://rhythmshahriar.com
# @author Rhythm <[email protected]>
# @copyright Copyright (c) 2013, Rhythm Shahriar
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
# Setup caching on media files for 1 year
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault A29030400
Header append Cache-Control "public"
</FilesMatch>
# Setup caching on media files for 1 week
<FilesMatch "\.(gif|jpg|jpeg|png|swf)$">
ExpiresDefault A604800
Header append Cache-Control "public"
</FilesMatch>
# Setup 2 Hour caching on commonly updated files
<FilesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "proxy-revalidate"
</FilesMatch>
# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
ExpiresActive Off
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment