Why use Cache-Control header in request?

血红的双手。 提交于 2019-12-11 05:12:32

问题


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:


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.



来源:https://stackoverflow.com/questions/42652931/why-use-cache-control-header-in-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!