This project is archived and is in readonly mode.

#3839 ✓stale
Bill Kirtley

When specifying public Cache-Control, also specify max-age

Reported by Bill Kirtley | February 2nd, 2010 @ 10:00 PM

The ActionController stale? and fresh_when functions will take a :public option, which will cause emission of a Cache-Control header with a public attribute.

Proxy caches will likely interpret a "Cache-Control: public" header to mean that the resource will never change, and will cache it forever.

If you're using either stale? or fresh_when, it's probably because the controlled resource does change over time, so you want to specify a max-age directive in the Cache-Control header to tell the proxy cache how long to serve the resource before asking the origin if it's changed.

Use of expires_in does set the max-age, and it is a workaround for this problem, but it feels awkward to have to do both.

Adding a :max_age option to fresh_when would deal with this nicely

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages