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


#1

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.

Age:2943
Cache-Control:public, max-age=3600
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:13851
Content-Type:text/css
Date:Thu, 18 Oct 2012 01:24:20 GMT
Last-Modified:Sat, 13 Oct 2012 02:52:50 GMT
Server:WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
Vary:Accept-Encoding
X-Content-Digest:94af71be4b455214a008971627ca52b848e40fc1
X-Rack-Cache:fresh


#2

On Wed, Oct 17, 2012 at 9:15 PM, Cary C. removed_email_address@domain.invalid wrote:

In config/environments/production.rb I have set

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

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.


#3

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?