Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling 304 Not Modified responses #84

Open
jcihocki opened this issue Jul 5, 2013 · 2 comments
Open

Disabling 304 Not Modified responses #84

jcihocki opened this issue Jul 5, 2013 · 2 comments

Comments

@jcihocki
Copy link

jcihocki commented Jul 5, 2013

It would be nice if there were an option to disable 304 not modified responses in the case where you want to do post-processing of cached content (in my case, ESI in non-production environments a la Varnish in production).

As far as I can tell, the HTTP specification does not prevent returning 200 with content even if the if-modified-since or if-match freshness condition is satisfied. This allows upstream processors to work their mojo and make the final determination as to whether 304 is appropriate or not.

In the case of ESI processing, this would allow me to catch edge caching bugs before production.

Thoughts?

@rtomayko
Copy link
Owner

rtomayko commented Jul 5, 2013

Yeah that makes sense to me. I'm curious, though, what other benefits would you want from rack-cache in that case? i.e., does it make sense to just remove rack-cache from the middleware pipeline entirely?

@jcihocki
Copy link
Author

jcihocki commented Jul 7, 2013

Right now removing rack-cache from the pipeline is the only option. The issue with that is your app may be returning public cache headers for content when inappropriate, but without an intermediary cache in dev/staging to surface the issue by returning the private/stale content you probably won't notice before promoting.

I considered the option of using ActionController#caches_page in dev and staging environments but 1) That's a fairly different request trajectory/code path so it's not really apples to apples 2) that mechanism is deprecated and has been removed from rails as of 4.1. and 3) It may well return 304 for fresh content as well for all I know.

The simple way to do this without touching rack-cache is to install a plugin before it in the pipeline that strips conditional get headers, but that is kind of a sledgehammer of an approach that won't work if your app needs to respond to those headers in some cases which is reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants