52

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

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 Expires set to "1981". What is the significance?

unor
  • 92,415
  • 26
  • 211
  • 360
footy
  • 5,803
  • 13
  • 48
  • 96

4 Answers4

113

It's an attempt to disable caching.

The date is the birthday of the developer Sascha Schumann who added the code.

From session.c:

Authors: Sascha Schumann <sascha@schumann.cx> 
         Andrei Zmievski <andrei@php.net> 

// ...

CACHE_LIMITER_FUNC(private)
{
    ADD_HEADER("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
    CACHE_LIMITER(private_no_expire)(TSRMLS_C);
}
Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452
  • 48
    Then happy birthday to him! ;-P – deceze Nov 19 '11 at 13:56
  • 2
    Omfg. I could've searched on for hours. - Thanks! See http://php.net/manual/de/function.session-cache-limiter.php – Fusselwurm Mar 19 '14 at 14:54
  • http://php.net/manual/en/function.session-cache-limiter.php add session_cache_limiter('public') before session_start() to enable caching – OSP Sep 03 '15 at 17:23
  • Was Sascha Schumann drunken or what??? Is this the fine art of programming to add private birthdays into Source Code??? – Ingo Jan 17 '17 at 21:13
  • 1
    @Ingo Why is it a such big problem? – klenium Feb 08 '17 at 16:16
  • 4
    @klenium: Because it is not intuitive! It should be a default Date like: 1.1.1900 etc. Then you not need such a thread. – Ingo Feb 11 '17 at 12:12
  • For anyone wanting to see the commit itself, the GitHub commit can be viewed here in the PHP source, committed on Dec 12, 1999: https://github.com/php/php-src/commit/996216b4991f74c749d7c47df817daa7ec2f1740 – Chris Hayes Oct 03 '22 at 19:17
10

HTTP Expires header

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.

Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
  • Yes...but as I know a session must expire at some point in time(unless I am wrong)....having the expiration date to 1981 how can we achieve that? – Dimitris Papageorgiou Aug 11 '15 at 11:20
  • @DimitrisPapageorgiou obviously, session will expire on different terms (and server-side session might last longer than user-side session). Expires header only tells user-browser, to not cache the response and request given URL again, if user requests it. – Marek Sebera Mar 16 '23 at 14:31
8

I think you are using session_cache_limiter before calling session_start. If argument is private or no-cache the result is setting the Expires header to the time you have mentioned. Refer to this document for more information.

Ashwini Dhekane
  • 2,280
  • 14
  • 19
0

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

deceze
  • 510,633
  • 85
  • 743
  • 889