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

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 😉

Leave a Comment