code_junkie

Removing Cache Busting in Rails Production

Nov 11th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. set :normalize_asset_timestamps, false
  2.  
  3. #Etags should be based on the file parameters only (default includes INode)
  4. FileETag MTime Size
  5.  
  6. #Rewrite stuff
  7. RewriteEngine On
  8.  
  9. #This sets the environment variable (is_versioned) when the URL query string
  10. #looks like ?874353948543 or any string of digits
  11. RewriteCond %{QUERY_STRING} ^[0-9]+$
  12. RewriteRule ^(.*)$ $1 [env=is_versioned:true]
  13.  
  14. <Directory /deployed-rails-app/public/ >
  15. Options -Indexes FollowSymLinks -MultiViews
  16. AllowOverride None
  17. Order allow,deny
  18. allow from all
  19.  
  20. #For files, force the browser to rely on cache-control directives and
  21. #Rails asset timestamps by removing Etags and Last-Modified dates
  22.  
  23. #For all assets that aren't stamped by rails, cache them for ~ 3 hours
  24. Header set "Cache-Control" "max-age=10000"
  25. Header unset Etag
  26. Header unset "Last-Modified"
  27.  
  28. #For all assets that ARE stamped by rails, cache them for 30 days
  29. Header set "Cache-Control" "max-age=2592000" env=is_versioned
  30.  
  31. </Directory>
Add Comment
Please, Sign In to add comment