gpt4 book ai didi

http - 在 Cache-Control HTTP header 中包含 max-age 和 s-maxage 有意义吗?

转载 作者:可可西里 更新时间:2023-11-01 15:05:00 24 4
gpt4 key购买 nike

考虑到 max-age 适用于所有缓存,而 s-maxage 仅适用于共享缓存(代理和网关缓存)......

在不可过期的公共(public)页面中同时使用这两个指令是否有意义?

Controller 伪代码:

w = Response();
w.setPublic();
w.setMaxAge("1 year");
w.setShareMaxAge("1 year");

return w;

最佳答案

来自 HTTP Header Field Definitions :

14.9.3 Modifications of the Basic Expiration Mechanism

...

s-maxage

If a response includes an s-maxage directive, then for a shared cache (but not for a private cache), the maximum age specified by this directive overrides the maximum age specified by either the max-age directive or the Expires header.

...

请注意,“覆盖”。因此,只有当您打算为共享缓存指定一个与最终用户将使用的 max-age 不同的最大期限时才有意义。

在您的特定示例中,它们是相同的,因此不需要指定 s-maxage

关于http - 在 Cache-Control HTTP header 中包含 max-age 和 s-maxage 有意义吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15971747/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com