Closed kpsherva closed 5 months ago
As far as I have seen, Vary
doesn't seem to fix anything. Browsers would still send If-Match: <Etag>
for requests with Accept: <different content-type than the request where we got the Etag in If-Match>
, then server would return 304
and cause the same bug.
FOR THE REVIEWERS: this is a proposal of the solution, it will be applied not only for the get method but please first share your thoughts
( addresses #250)
Update: The main issue seemed to be that the vary header had no effect if the
etag
was unchanged so the new WIP version has theetag
include not only therecord.revision_id
but also the mimetype. It's still unclear which effect theVary
header has but without it sometimes it doesn't recognize if a change is made in theAccept
header so it seems to be needed.Requires https://github.com/inveniosoftware/invenio-rest/pull/100
PAST NOTES ON THE ISSUE:
THIS IS not working fully - below my investigation How to test:
You can use firefox for debugging - it has neat way of editing headers in the dev tools
/records/1
Vary: Content-Type, Accept
header - check this PRapplication/x-custom
in the request and request again the endpoint. You will get the same json response, cached, while you should get 200 status code response with x-custom content type. What is probably the problem here: The cached response is not adding the Vary header so the browser does not know that it should check the Accept value every time, and relies only on the combination ofETag
(which is version of the record) passed toIf-None-Match
header andIf-Modified-Since
header which won't change in this case.