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

后端 未结 2 1438
野性不改
野性不改 2021-01-30 12:53

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 ET

2条回答
  •  無奈伤痛
    2021-01-30 13:18

    The answer is: it depends.

    Suppose we have received

    If-None-Match: *
    If-Modified-Since: 
    

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

提交回复
热议问题