Vary: Origin
should not be set if the Origin
request header is ignored
#332
Labels
Vary: Origin
should not be set if the Origin
request header is ignored
#332
The
Vary
HTTP response header is useful to ensure proper caching of CORS responses and prevent cache poisoning. However, it comes with a downside: (potentially significantly) increasing the cache size, since each client's origin will create a different cached value.The standard mentions:
In other words, if the CORS response is always the same regardless of the
Origin
request header,Vary: Origin
should not be set. Currently, this module mostly gets it right except in two cases:origin
option is a function, regardless of the return value of that function (including'*'
),Vary: Origin
should be set, since that function might (and most likely did) use theOrigin
request header.cors/lib/index.js
Lines 209 to 216 in 53312a5
cors/lib/index.js
Lines 41 to 46 in 53312a5
origin
option is a string,Vary: Origin
should not be set, sinceAccess-Control-Allow-Origin
is always the same value, and theOrigin
request header is ignored.cors/lib/index.js
Lines 47 to 56 in 53312a5
The text was updated successfully, but these errors were encountered: