What does the following HTTP 1.1 header mean?
If-None-Match: *
I understand it when using a strong or weak ETag or even a list of ETags, but I don't understant it's use when using star (*).
Edit: Would be nice to have some pseudocode (PHP code good also) that would show how/what to answer to "If-None-Match: *".
The If-Match HTTP request header makes a request conditional. A server will only return requested resources for GET and HEAD methods, or upload resource for PUT and other non-safe methods, if the resource matches one of the listed ETag values.
The If-Modified-Since header is used to specify the time at which the browser last received the requested resource. The If-None-Match header is used to specify the entity tag that the server issued with the requested resource when it was last received.
1 If-Match: W/"d14c91f83b4554b6" Select the correct answer: The server should NOT include PATCH instructions in the Response body if the resource is semantically equivalent to the version referenced by the "d14c91f83b4554b6" ETag. The server should NOT include PATCH.
The answer is: it depends.
Suppose we have received
If-None-Match: * If-Modified-Since: <yesterday date>
And the page has been altered today.
First, we take a look at the *
which tells us: "Return 304 if the resource is there and condition (2) is met". Fine, the resource exists, BUT condition (2) states: "Only return 304, if the date is later than current". So this condition is not met, and the page will be delivered completely.
If we hadn't received If-Modified-Since
, the response would have been 304.
If the resource hadn't existed upon request, we'd have returned the appropriate code (as if there was no If-None-Match
).
304 should only be returned in response for GET and HEAD requests, and all cache-related response headers have to be there. For all other types of request your server needs to be answering 412 (Precondition failed).
I hope it helps ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With