Cary Cherng
2012-Oct-18 02:15 UTC
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. 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/DRuhaghls7gJ. For more options, visit https://groups.google.com/groups/opt_out.
Jordon Bedwell
2012-Oct-18 07:12 UTC
Re: Why is max-age in config.static_cache_control being ignored?
On Wed, Oct 17, 2012 at 9:15 PM, Cary Cherng <ccherng-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Cary Cherng
2012-Oct-18 22:17 UTC
Re: Why is max-age in config.static_cache_control being ignored?
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? On Thursday, October 18, 2012 12:14:44 AM UTC-7, Jordon Bedwell wrote:> > On Wed, Oct 17, 2012 at 9:15 PM, Cary Cherng <cch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<javascript:>> > 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. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/hs5WgJ3whkgJ. For more options, visit https://groups.google.com/groups/opt_out.