Skip to content

Instantly share code, notes, and snippets.

@gordonbanderson
Created July 19, 2010 06:40
Show Gist options
  • Save gordonbanderson/481076 to your computer and use it in GitHub Desktop.
Save gordonbanderson/481076 to your computer and use it in GitHub Desktop.
ExpiresActive On
Options FollowSymLinks MultiViews
#Do these from rails explicity
#ExpiresByType text/html "access plus 1 minute"
#Do this from Apache
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 week"
# special MIME type for icons - see http://www.iana.org/assignments/media-types/image/vnd.microsoft.icon
AddType image/vnd.microsoft.icon .ico
# now we have icon MIME type, we can use it
# my favicon doesn't change much
ExpiresByType image/vnd.microsoft.icon "access plus 3 months"
#Etags should be based on the file parameters only (default includes INode)
FileETag MTime Size
#Rewrite stuff
RewriteEngine On
#This sets the environment variable (is_versioned) when the URL query string
#looks like ?874353948543 or any string of digits
RewriteCond %{QUERY_STRING} ^CACHE201007183$
RewriteRule ^(.*)$ $1 [env=is_versioned:true]
#For all assets that aren't stamped by rails, cache them for ~ 3 hours
#Header set "Cache-Control" "max-age=62"
#Header unset ETag << does not seem to work
#Header unset "Last-Modified"
#For all assets that ARE stamped by rails, cache them for 30 days
Header set "Cache-Control" "max-age=31536000" env=is_versioned
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment