res: include Access-Control-Allow-Origin when generating ETag#6884
res: include Access-Control-Allow-Origin when generating ETag#6884shivank-1011 wants to merge 1 commit intoexpressjs:masterfrom
Conversation
Include the response Access-Control-Allow-Origin header as an extra argument to the app's compiled etag function so ETags vary by CORS origin. This prevents CDN/304 + missing CORS headers from causing browser CORS errors. Backwards compatible: custom etag functions may ignore the extra arg.
|
EDIT: Read #5986 for more details. I don't think that ACAO should affect ETag value. ETag is about selected representation, which I understand to be the response data and metadata such as language, encoding and type. If you serve different ACAO headers, then I assume it is based on the request
When this header is present, the cache MUST use request headers listed in response's If you'd like to read more, here are some references:
|
Include the response Access-Control-Allow-Origin header as an extra argument to the app's compiled etag function so ETags vary by CORS origin. This prevents CDN/304 + missing CORS headers from causing browser CORS errors. Backwards compatible: custom etag functions may ignore the extra arg.
Fix: ETag should vary by CORS origin
Summary
Fixes a bug where responses with the same body but different
Access-Control-Allow-Originheaders produced identical ETags.Details
res.send()now passes the response’sAccess-Control-Allow-Originvalue to the ETag generator so that ETags differ per origin.This prevents caches or CDNs from serving incorrect 304 Not Modified responses that omit or mismatch CORS headers.
Changes
Access-Control-Allow-Originto the ETag generator.Notes