What to do if the HTTP headers include If-Modified-Since and If-None-Match

I have read RFC 2616 - sec.14.26 and RFC 2616 - sec13.3.3 for quite some time, but I'm still not sure if I understand correctly.

Section 14.26 states that

If any of the entity tags matches the entity tag of the object that would be returned in response to a similar GET request (without the If-None-Match header) on this resource, or if "*" is given, and any existing object exists for this resource , then the server SHOULD NOT execute the requested method, unless it is required, because the date the resource was changed does not match what is provided in the If-Modified file. Since the header is in the request. Instead, if the request method was GET or HEAD, the server MUST respond with a 304 (Not Modified) response, including header fields associated with the cache (specifically ETag) of one of the entities that matched.

If none of the entity tags matches , then the server MAY execute the requested method as if the If-None-Match header field does not exist, but MUST also ignore any If-Modified-Since header field (s) in the request. That is, if the entity tags do not match, the server SHOULD NOT return a 304 response (unchanged) .

and section 13.3.3 states that

The HTTP / 1.1 origin server after receiving a conditional request that includes both the last modified date (for example, in the If-Modified-Since or If-Unmodified-Since header field) and one or more object tags (for example, in the header field If-Match, If-None-Match, or If-Range) as validation caches, SHOULD NOT return the response status of 304 (Not Modified), unless that matches the entire conditional field header in the request.

I'm rather confused if an unconditionally compatible HTTP server should respond to a client request ( GET / HEAD ), where

  • If-Modified-Since condition is met, but If-None-Match does not work.
  • or, the If-None-Match condition is If-None-Match , but If-Modified-Since not.

According to section 14.26, 304 Not Modified must be returned in the first case and 200 OK in the second case, since If-Modified-Since ignored.

But section 13.3.3 says that "it SHOULD NOT return the response status of 304 (unchanged), unless that matches all conditional header fields in the request." This means that you need to return 200 OK in both cases.

+8
source share
1 answer

from RFC 7232

The receiver should ignore If-Modified-Since if the request contains an If-None-Match header field; a condition in If-None-Match is considered a more accurate replacement for a condition in If-Modified-Since, and they are only combined to interact with older intermediaries that may not implement If-None-Match.

+10
source

All Articles