httpcachingvary

Should I specify "Vary: If-None-Match, If-Modified-Since"?


RFC 7231:

The "Vary" header field in a response describes what parts of a
request message, aside from the method, Host header field, and
request target, might influence the origin server's process for
selecting and representing this response.


Solution

  • No.

    The RFC says:

    An origin server SHOULD send a Vary header field when its algorithm for selecting a representation varies based on aspects of the request message other than the method and request target

    In this case, the representation is not determined by the value of those headers. They are used to decide whether or not a body should be sent.

    As a hint:

    For example, there is no need to send the Authorization field name in Vary because reuse across users is constrained by the field definition

    Likewise for for conditional request fields.