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

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

问题描述

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

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

我了解 HTTP 响应标头(服务器到客户端)中的 Cache-Control 字段通过发送不同的值指定了中间代理服务器/客户端浏览器如何处理响应的指令对于 Cache-Control 字段:privatepublicno-cacheno-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 we need to send Cache-Control as a request header (client to server)?

推荐答案

Cache-Control: no-cache 一般用于请求头(从浏览器发送到服务器)强制验证中间代理中的资源.如果客户端没有将此请求发送到服务器,中间代理将返回内容的副本(如果它是新鲜的(根据 Expiremax-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天全站免登陆