action-center-platform icon indicating copy to clipboard operation
action-center-platform copied to clipboard

issue appropriate HTTP headers for cacheability

Open mfb opened this issue 9 years ago • 3 comments

When a user is /not/ logged in, the app should issue appropriate headers to allow caching by reverse proxies like Fastly, as well as by the user's browser. It should also set a Vary: Cookie header so that the cache will vary based on the user's cookie, e.g.:

Cache-Control: max-age=3600, public Vary: Cookie, Accept-Encoding

Note: 3600 is just an example, and should be configurable.

When a user is logged in, the app should issue appropriate headers to disallow caching by Fastly or the browser, e.g.:

Cache-Control: must-revalidate, no-cache, private Vary: Accept-Encoding

This is a new issue to replace issues on the old project:

  • https://github.com/EFForg/actioncenter-dontuseforissues/issues/423
  • https://github.com/EFForg/actioncenter-dontuseforissues/issues/424

The goal is that the app could be installed behind any reverse proxy and pretty much "just work" without any additional configuration of the reverse proxy.

mfb avatar Sep 20 '16 20:09 mfb

We might also need to set a vary header based on the Accept header. The action center is returning html for act.eff.org/action even when "accept: application/json" is set.

vbrown608 avatar Oct 17 '16 22:10 vbrown608

that would be Vary: Accept and would be unfortunate since it decreases cacheability even more. I know it's not very RESTfulicious but could we use a different endpoint for json, i.e. https://act.eff.org/action.json

mfb avatar Oct 17 '16 22:10 mfb

Vary: Accept-Encoding is to support compressed output which I just noticed we're not doing. I'm going to file a redmine bug about that.

mfb avatar Oct 17 '16 22:10 mfb