PHP 会话发送标头“Cache-Control:no-store、no-cache、must-revalidate”。如何更改为“Cache-Control: s-maxage=10, public, max-age=10”
PHP 会话导致每个页面都包含标头 cache-control: no-store, no-cache, Must-revalidate
。
我需要重写此行为并将其更改为 Cache-Control: s-maxage=10, public, max-age=10
甚至只是 cache-control: public, max-age= 10.
.
我尝试使用会话变量 session_cache_limiter('public');
和 session_cache_expire(1);
但是,过期值以分钟为单位,我无法弄清楚如何将其设置为 10 秒。
如何将 session_cache_expire(1);
设置为 10 秒? 如果这是不可能的,我还能如何覆盖会话标头并将缓存控制设置为 10 秒?
PHP session is causing each page to contain the header cache-control: no-store, no-cache, must-revalidate
.
I need to override this behavior and change it to Cache-Control: s-maxage=10, public, max-age=10
or even just cache-control: public, max-age=10
.
I've tried to use session variables session_cache_limiter('public');
and session_cache_expire(1);
but, the expire value is in minutes and I cant work out how to set it to 10 seconds.
How can I set session_cache_expire(1);
to 10 seconds?
If that's not possible, how else can I override the session header and set the cache control to 10 seconds?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在@Amikot40 和@CBroe 的帮助下,我解决了这个问题。
With the help of @Amikot40 and @CBroe, I've solved the issue.
在 PHP 中,您使用 header() 函数:
替代选项是在顶部使用 HTML 标签 - 在第一个
如果您使用任何具有模板的前端框架 - 您应该在那里查找元标记,或者可能在其中查找元标记框架文档(可能有专门的功能)。
In PHP you use header() function:
Alternate option is to use HTML tags on top - before first <?php opening:
If you using any frontend framework which has its templates - you should look for meta tags there, or possibly in that framework documentation (possibly there are dedicated functions for that).