简体   繁体   English

为什么在请求中使用Cache-Control标头?

[英]Why use Cache-Control header in request?

This page on Cache-Control specifies the following: Cache-Control上的此页面指定以下内容:

Standard Cache-Control directives that can be used by the client in an HTTP request. 客户端可以在HTTP请求中使用标准Cache-Control指令。

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? 客户端为什么要向服务器发送缓存信息?

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" max-age -“我不希望响应早于X”
  • no-cache - "I want a fresh response" no-cache -“我想要一个新的回应”
  • no-transform - "I don't want it unless it's the original" no-transform -“除非原始格式,否则我不想要”
  • only-if-cached - "Don't bother the origin server if you don't have it already" only-if-cached -“如果您还没有原始服务器,请不要打扰”

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. 仅仅因为客户坚持未缓存的响应并不意味着一定会得到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM