Why is max-age in config.static_cache_control being ignored?

In config/environments/production.rb I have set

config.serve_static_assets = true

config.static_cache_control = “public, max-age=1000”

But the response header for application-fingerprint.css is something like the following where you can see max-age hasn’t been changed to 1000. I’m assuming this is the result of some interaction with rack-cache but I don’t know how to solve my problem.


Cache-Control:public, max-age=3600





Last-Modified:Sat, 13 Oct 2012 02:52:50 GMT

Server:WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)




If I remember right, anything served from /app/assets is not
considered static to the system because it requires more to route it,
but anything in /public should be considered a static asset and will
fall under your cache control. Since I normally handle all my headers
via Apache or Nginx I don't remember if this is entirely the case
anymore but again if I remember right everything again in /app/assets
is considered compiled on the fly unless you compile it to /public.

I solved my problem by running

RAILS_ENV=production bundle exec rake assets:precompile

It appears that the setting for config.static_cache_control is being lazily cached.

If I do the following, I get back max-age=1000 in the response header

config.static_cache_control = “public, max-age=1000”

precompile assets

start webrick

visit webpage

However if I do the following I don’t get back max-age=1000, instead I get max-age=2000

config.static_cache_control = “public, max-age=1000”

precompile assets

start webrick

close webrick

config.static_cache_control = “public, max-age=2000”

start webrick

visit webpage

Can someone explain to me how this is possible and give a model for how config.static_cache_control is being saved?