Skip to content

Instantly share code, notes, and snippets.

@xenda
Created November 15, 2009 19:13
Show Gist options
  • Save xenda/235415 to your computer and use it in GitHub Desktop.
Save xenda/235415 to your computer and use it in GitHub Desktop.
#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} ^[0-9]+$
RewriteRule ^(.*)$ $1 [env=is_versioned:true]
<Directory /deployed-rails-app/public/ >
Options -Indexes FollowSymLinks -MultiViews
AllowOverride None
Order allow,deny
allow from all
#For files, force the browser to rely on cache-control directives and
#Rails asset timestamps by removing Etags and Last-Modified dates
#For all assets that aren't stamped by rails, cache them for ~ 3 hours
Header set "Cache-Control" "max-age=10000"
Header unset Etag
Header unset "Last-Modified"
#For all assets that ARE stamped by rails, cache them for 30 days
Header set "Cache-Control" "max-age=2592000" env=is_versioned
</Directory>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment