What headers do I want to send together with a 304 response?

前端 未结 2 374
既然无缘
既然无缘 2021-02-05 10:56

When I send a 304 response. How will the browser interpret other headers which I send together with the 304?

E.g.

header(\"HTTP/1.1 304 Not Modified\");
         


        
2条回答
  •  隐瞒了意图╮
    2021-02-05 11:35

    The Content-Type header only applies to responses which contain a body. A 304 response does not contain a body, so that header does not apply. Similarly, you don't want to send Last-Modified or ETag because a 304 response means that the document hasn't changed (and so neither have the values of those two headers).

    For an example, see this blog post by Anne van Kesteren examining WordPress' http_modified function. Note that it returns either Last-Modified and ETag or a 304 response.

提交回复
热议问题