Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the HTTP header If-None-Match: * mean?

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: *".

like image 346
AlexV Avatar asked Jan 21 '10 18:01

AlexV


People also ask

What is an IF-Match header?

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.

What are the If modified since and if-none-match header used for?

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.

What does it mean when a patch request has the following header 1 if-match w d14c91f83b4554b6 select the correct answer?

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.


1 Answers

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 ;)

like image 146
St.Woland Avatar answered Sep 18 '22 12:09

St.Woland