HTTP Header Vary - Order of values

432 views Asked by At

We serve files for our websites to which we add CORS headers. The Vary header is required for cache management at the CDN and browser level.

So the question: is there any importance in the order of the values in this header?

Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method, Accept-Encoding

An application at one of our CDN providers adds a Vary header in addition to ours. This results in the following:

Vary: Accept-Encoding
Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method, Accept-Encoding

We know that we can declare it multiple times according to the RFCs; the concern is what happens to the order of the elements for this parameter.

Thanks.

1

There are 1 answers

0
Tgr On

No. Vary means the cached response should only be used if the value of all listed headers matches. (To quote the RFC, "... cache recipients ... MUST NOT use this response to satisfy a later request unless the later request has the same values for the listed fields as the original request ... In other words, Vary expands the cache key required to match a new request to the stored cache entry.") There is no meaningful way to involve the order or priority of headers in that condition.