What takes precedence: the ETag or Last-Modified HTTP header?

后端 未结 3 2053
生来不讨喜
生来不讨喜 2020-12-07 12:24

For two subsequent requests, which of the following two headers is given more weight by browsers should one of them change: ETag or Last-Modified?

3条回答
  •  粉色の甜心
    2020-12-07 12:26

    =! is the correct comparison operator. The client is required to keep the literal string received from the server, as conversions can create small differences. You can not assume that 'newer is better'.

    Why? Consider the case where the server operator reverts a bad version of a resource. The reverted version is OLDER - but correct.

    The client must use the version currently offered by the server; it can use a cached version only if it is the same. Thus the server must check equality, not 'newer'.

提交回复
热议问题