Why use Cache-Control header in request?

Posted zzfx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Why use Cache-Control header in request?相关的知识,希望对你有一定的参考价值。

本地缓存也是缓存代理的一部分。

请求时使用Cache-Control 表示缓存的使用策略。

 

请求头里的no-cache表示浏览器不想读缓存,并不是说没有缓存。一般在浏览器按ctrl+F5强制刷新时,请求头里就有这个no-cache,也就是跳过强缓存和协商缓存阶段,直接请求服务器。(如果直接按F5的话,请求头是max-age=0,只跳过强缓存,但进行协商缓存)
而响应头max-age=259200 ,不太清楚,没验证出来

http://bbs.csdn.net/topics/391022213

 

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

 

Cache-Control: no-cache is generally used in a request header (sent from web browser to server) to force validation of the resource in the intermediate proxies. If the client doesn‘t send this request to the server, intermediate proxies will return a copy of the content if it is fresh (has not expired according to Expire or max-age fields). Cache-Control directs these proxies to revalidate the copy even if it is fresh.

https://stackoverflow.com/questions/14541077/why-is-cache-control-attribute-sent-in-request-header-client-to-server

以上是关于Why use Cache-Control header in request?的主要内容,如果未能解决你的问题,请参考以下文章

Why is Blast useful?

Why Use the Widget Factory?

Why does OpenCV use BGR color format ?

Why SignalR does not use WebSockets?

Why I don't want use JPA anymore

Why using constructor based dependency injection | Spring