php 为什么“过期”是 1981 年?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8194481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 04:07:40  来源:igfitidea点击:

Why is "Expires" 1981?

phpsessionexpires-header

提问by footy

My CRON Job returned an error that CRON job did not work. In that this was there:

我的 CRON 作业返回了 CRON 作业不起作用的错误。就在那里:

Set-Cookie: PHPSESSID=2t2drultihqci4em15nbfmeb63; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-type: text/html

I am wondering why is Expiresset to "1981". What is the significance?

我想知道为什么Expires设置为“1981”。有什么意义?

回答by Mark Byers

It's an attempt to disable caching.

这是禁用缓存的尝试。

The date is the birthday of the developer Sascha Schumannwho added the code.

日期是添加代码的开发人员Sascha Schumann的生日。

From session.c:

从 session.c:

Authors: Sascha Schumann <[email protected]> 
         Andrei Zmievski <[email protected]> 

// ...

CACHE_LIMITER_FUNC(private)
{
    ADD_HEADER("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
    CACHE_LIMITER(private_no_expire)(TSRMLS_C);
}

回答by Marek Sebera

HTTP Expires header

HTTP 过期标头

http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

It is set to negative or past value, to prevent caching of response.

它被设置为负值或过去值,以防止缓存响应。

Quite common usage of this header.

此标头的常见用法。

回答by Ashwini Dhekane

I think you are using session_cache_limiterbefore calling session_start. If argument is privateor no-cachethe result is setting the Expiresheader to the time you have mentioned. Refer to thisdocument for more information.

我认为您session_cache_limiter在调用session_start. 如果参数是privateno-cache结果将Expires标题设置为您提到的时间。有关更多信息,请参阅文档。

回答by deceze

Somebody just put expires = date('-30 years')(paraphrased) in his code to make really sure the content is set as expired and not cached.

有人只是expires = date('-30 years')在他的代码中放入(释义)以确保将内容设置为已过期而不是缓存。