What is the function of the “Vary: Accept” HTTP header?

前端 未结 4 756
予麋鹿
予麋鹿 2020-11-28 19:19

I use PHP to generate dynamic Web pages. As stated on the following tutorial (see link below), the MIME type of XHTML documents should be \"application/xhtml+xml\" when $_SE

4条回答
  •  离开以前
    2020-11-28 19:54

    Vary: Accept simply says that the response was generated based on the Accept header in the request. A request with a different Accept header might get a different response.

    (You can see that the linked PHP code looks at $HTTP_ACCEPT. That's the value of the Accept request header.)

    To HTTP caches, this means that the response must be cached with extra care. It is only going to be a valid match for later requests with exactly the same Accept header.

    Now this only matters if the page is cacheable in the first place. By default, PHP pages aren't. A PHP page can mark the output as cacheable by sending certain headers (Expires, for example). But whether and how to do that is a different question.

提交回复
热议问题