Does the ETag header make the Cache-Control header obsolete? How to make sure Cache-Control is not harmful then?

前端 未结 2 1279
花落未央
花落未央 2021-01-22 18:42

Definition of ETag header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag):

The ETag HTTP response header is an identifier for a specific

2条回答
  •  花落未央
    2021-01-22 19:24

    Presence of ETag header does not tell the browser to do anything. Browser decides what to do based on the Cache-Control header it receives in the request and cached response. If it decides that resource is stale or needs to be re-validated, then it can use the ETag value to create a conditional request to the server and either get a new resource (status code 200), or a notification that things have not changed (status code 304)

    Both headers are necessary for your cache to work optimally.

提交回复
热议问题