Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails config.static_cache_control how to exclude files from cache

I'm setting long term expires headers on all of my assets. However, there are some static HTML files (for a Jekyll blog) in my public directory, that are getting cached and there is no cache busting in place for them when updated. It actually just seems to be my main index.html file, located in app/public/blog, that keeps getting caught in the cache.

Is it as simple as changing the "public" in the config?

config.static_cache_control = "public, max-age=604800"

like image 275
Galen Avatar asked Apr 22 '13 19:04

Galen


1 Answers

I know this is an old question, but I keep finding it, when I look this up (I keep looking this up), so here's the answer:

No, the public in config.static_cache_control does NOT refer to the rails public/ directory.

In fact this whole string is a literal used as the Cache-Control header when serving static assets (including both public/ and sprockets-compiled assets in assets/).

See http://guides.rubyonrails.org/asset_pipeline.html#cdns-and-the-cache-control-header for the details on how config.static_cache_control is used in rails and http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 for the w3c docs on the meaning of the Cache-Control header.

like image 129
Tim Diggins Avatar answered Sep 21 '22 08:09

Tim Diggins