-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Cache-Control header behavior has changed in 1.4.x #2110
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
Comments
I believe I see why: response_object = stream || [body] This is calling the |
This looks like it's fixed in master, but I really recommend pushing a patch version for this at 1.4.1, this can really be bad for folks behind a CDN. |
If you really want to do a 1.4.1 patch go for it @bobbytables, otherwise i'll release 1.5.0 soon (unless someone beats me to it). |
Hey there, we've recently upgraded our version of Grape from 1.2.2 -> 1.4.0. We saw a sudden spike in cached requests in our CDN (Fastly) for our API. Fastly relies on the
Cache-Control
header to determine if it should or should not cache the response.We also use the
Rack::ETag
middleware (default in Rails afaik), which by default sets theCache-Control
header, see here: https://github.com/rack/rack/blob/master/lib/rack/etag.rb#L18However, this middleware will not set the cache control header if one is already present. See: https://github.com/rack/rack/blob/master/lib/rack/etag.rb#L39
This is where I believe Grape introduced a difference, I have a request spec that added an assertion to verify these findings:
In Grape 1.2.5, this passes, in Grape 1.4.0 however...
I believe something has changed in the way that Grape assigns response headers, including the Cache-Control header. And my gut is that is has something to do with this change in the compare I looked through:
https://github.com/ruby-grape/grape/compare/v1.2.2..v1.4.0#diff-417f63bb9cd022ea7ea57549e03fcb5bR33-R54
This is a potential security risk for people
This change can cause API responses to be cached in CDNs unbeknownst to people upgrading Grape and served to other users for an API endpoint they do not have access to simply because they hit some endpoint with a unique identifier (
/api/tasks
for example)The text was updated successfully, but these errors were encountered: