为什么在请求标头(客户端到服务器)中发送Cache-Control属性? [英] Why is Cache-Control attribute sent in request header (client to server)?

查看:202
本文介绍了为什么在请求标头(客户端到服务器)中发送Cache-Control属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读HTTP标头的Cache-Control字段后,

After reading about the Cache-Control field of the HTTP header,

我理解HTTP响应头(服务器到客户端)中的Cache-Control字段指定中间代理服务器/客户端浏览器关于如何处理响应的指令,通过在响应头中发送Cache-Control字段的不同值 - private,public,no-cache或no-store。

I understand that the Cache-Control field in the HTTP response header (server to client) specifies the directives for the intermediate proxy servers/client browser on how to handle the response, by sending different values for the Cache-Control field - private, public, no-cache or no-store in the response header.

但我不明白为什么我们需要在请求头(客户端到服务器)中发送Cache-Control属性?

But I don't get why do we need to sent the Cache-Control attribute in the request header (client to server)?

推荐答案

Cache-Control:no-cache 通常用于请求标头(从Web浏览器发送到服务器)以强制验证中间代理中的资源。
如果客户端没有将此请求发送到服务器,则中间代理将返回内容的副本(如果它是新的(根据 Expire 未过期)或 max-age 字段)。 Cache-Control 指示这些代理重新验证副本,即使它是新的。

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.

这篇关于为什么在请求标头(客户端到服务器)中发送Cache-Control属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆