Why use Cache-Control header in request?

2019-07-29 07:26发布

This page on Cache-Control specifies the following:

Standard Cache-Control directives that can be used by the client in an HTTP request.

I thought that only servers send back information on whether a client should cache a response. Why would a client send a caching information to the server?

1条回答
淡お忘
2楼-- · 2019-07-29 07:57

There may be any number of intermediate proxies between the client and server which do caching. The client can explicitly request explicit caching behaviour from any and all caching entities, things like:

  • max-age - "I don't want a response older than X"
  • no-cache - "I want a fresh response"
  • no-transform - "I don't want it unless it's the original"
  • only-if-cached - "Don't bother the origin server if you don't have it already"

As with all requests, servers have a certain leeway in whether to honour the request or not. Just because a client insists on an uncached response doesn't mean it's necessarily going to get it.

查看更多
登录 后发表回答