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
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?