有关ETAG和缓存控制标头的问题
我正在尝试自定义缓存策略。
不适合我。
因为默认设置 强>
请检查我的理解是否正确。
首先,我的响应数据不经常变化。 但偶尔会改变。
这是我的计划。
也许我应该每次重新估计。因此,我需要设置我的CACH-CORTORL
这样。
Cache-Control: public max-age=0 must-revalidate
我想,通过这种方式,我的数据将存储在客户端浏览器
中 并且浏览器将始终发送检查值是新的请求。
在服务器上,我将编写代码来处理以下行中写的内容。
首先,将ETAG放在响应标头上。
第二,如果
如果不匹配
值来自请求标题,我将其与我的服务逻辑进行比较以检查值是否最新。如果
如果不匹配
值是最新的,我只是在响应中编写304并发送。,否则,我只是正常响应数据。具有新的ETAG值。
I am trying to customize cache strategy.
because default setting is not fit on me ... Serviced by (Vercel).
I am unfamiliar with the cache setting through the http header, so I would like to ask for help.
Please check if my understanding is correct.
First of all, my response data doesn't change often.
But occasionally it changes.
Here is my plan.
Maybe i should revalidate every time. so i need to set my Cache-Control
like this.
Cache-Control: public max-age=0 must-revalidate
I guess, with this way, my data will be stored in the client browser
and the browser will always send request that check the value is new.
And on the server, i'll write code to handle the things written in the lines below.
First, set Etag on response header.
Second, if the
If-None-Match
value comes from the request header, I compare it with my service logic to check whether the value is up to date.If the
If-None-Match
value is up to date, I just write 304 in the response and send it.And otherwise, I just respond with the data normally. with the new Etag value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论