Reputation: 1
Wonder if anyone can help me with this. I have been trying to set Etags and cache-control to public in Rails 4.1 with no luck. In a development machine, it all works fine as it should, but in production when I check the browser headers it's always "Cache-Control: private, must-revalidate, max-age=0" with no signs of an etag.
Using fresh_when or stale such as: if stale?(etag: etag_here, public: true) it's like these functions don't exist as they just don't do anything. The etag doesn't appear and cache-control doesn't change from private to public.
When I set Last Modified, that appears in the header ok.
Since this only occurs in production, I've tried a few things to see if i can get it to work:
Changed Apache to Nginx on my server. No luck. Disabled Gzip. No luck. Tried to put "W/" at the beginning of etag for weak etag. No luck. I have even started a BRAND NEW app with no other gem but the standard ones and tried to set the etag and cache control to public. Still no luck.
So not even when I create a new app, etag and cache-control still don't work.. Gzip is off on nginx and both Rack::ConditionalGEt and Rack::Etag are both present at the end of my middleware, they're just not being saved into the headers.
Any reply would be appreciated. Thanks.
Upvotes: 0
Views: 872
Reputation: 7569
I found out why this isn't work in my case. I have google page_speed
module compiled into nginx. And when I turn off page_speed
, etag
works now.
Upvotes: 0