Closed (fixed)
Project:
JSON:API
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
2 Jan 2018 at 16:28 UTC
Updated:
2 Mar 2018 at 20:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
e0ipsoWhat about a HEAD request seeking for a fast 304 using an etag and an
If-None-Matchheader? We'd want to be able to cache the response when the http method + etag are part of the cache key.I am not sure why HEAD requests should not have page cache support.
Comment #3
gabesulliceI believe @e0ipso is right. See:
See also,
Comment #4
wim leersI agree :) My issue summary was very very very brief, too brief, and hence probably confusing.
HEAD === body-less GET. A
HEADrequest is treated the same as aGETrequest by Drupal, including Page Cache.Both a
HEADrequest or aGETrequest will result in the fullGETresponse being stored in Page Cache. Symfony strips the response body at the last moment.The REST module's integration test coverage even explicitly tests this in detail, because
HEADrequests are important for API-first use cases:The port of this test coverage to JSON API in #2930028: Comprehensive JSON API integration test coverage phase 1: for every entity type, individual resources only already includes those same assertions:
It's that test coverage that made me notice that JSON API did not yet support HEAD requests.
And it's related test coverage that made me discover that JSON API's responses to
PATCHandPOSTrequests are cacheable responses (which is why they contain cache tags and contexts even though they should not). That is what this issue is about.Comment #5
wim leersComment #6
e0ipsoThanks for the clarifications @Wim Leers. I took the previous issue title to literally.
Comment #7
wim leersMy bad!
Comment #8
wim leersActually, #2883086-17: [PP-1] Port RequestHandler + ResourceResponseSubscriber improvements from REST module to JSON API would also fix this! This is pretty much a subset of that issue.
Comment #9
wim leersComment #10
wim leers#2930028: Comprehensive JSON API integration test coverage phase 1: for every entity type, individual resources only and #2932031: Comprehensive JSON API integration test coverage phase 2: for every entity type, complex use-cases landed, now we can do this with very strong assurances we don't break anything!
Comment #11
wim leersFixing this results in the minimal set of changes that makes all cacheability-related assertions pass that #2930028 and #2932031 added, but needed to provide work-arounds for.
Comment #12
wim leersGreen on both 8.4 and 8.6!
These (and many more like those last two) are the work-arounds that the test coverage issues were forced to introduce in order to have passing tests, and which is what this issue is fixing. This issue is single-handedly fixing all cacheability issues!
Comment #14
wim leers