Why Is "Expires" 1981

Why is Expires 1981?

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);
}

What happens if the origin web server sets the expires value in response header as a time which is passed relatively long ago?

Responding with a past date in the Expired header (earlier than the Date header value) makes no sense and would be a sign of some serious misconfiguration. That being said, clients would treat such response as "already expired" and not cache it. Same applies if Expires date is equal to Date header value (which is the correct way of server marking the response as "already expired") or having an invalid format.

See the Expires section of RFC 2616 for details.

Http headers: Expires

The significance of this Date is the Sascha Schumann birthday who Developed this code.

You Can Change it 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);
}

Reduce Expires Header SEO

You cannot change the headers sent by websites you don't control.

Facebook, Twitter, StumbleUpon and Google all control their own headers and have their own reasons for the expiration time and other cache settings that they send through.

You can only make these changes on a domain that you control. In this case your options are:

  • Consider alternative ways to connect to these social networks. For example, you could code your own custom scripts, or find a Wordpress plugin that will run locally on your page (even with this, you may not totally be able to remove reliance on these external scripts, depending on the exact functionality you want)

  • Don't get hung up trying to get good results for everything GTMetrix tells you. Don't get me wrong, GTMetrix's suggestions are great and you can learn a lot from them, but it's rarely possible to do absolutely everything 100% of the time. Do your best, do what's under your control, and you'll definitely notice your site's speed (and hopefully ranking) increase.

For what it's worth, installing a local caching plugin like W3 Total Cache generally deals with several of GTMetrix's metrics in one go!

Symfony response cache controll headers duplicate

PHP is overriding your caching settings, that "Expires" date is very specific and included in the PHP source code. According to this stack overflow answer, it is the developer's birthday.

You can turn this off by changing the session.cache-limiter setting in your php.ini. The session_cache_limiter function page has more information about the possible values to set here. Try setting the value to public or to nothing and testing again.

You can see what the current value of the session.cache_limiter setting is with a small test page which echos the value:

<?php

echo(ini_get('session.cache_limiter'));

You said you are looking for a PHP solution, since you cannot edit host settings. You can change the value inside your code using the ini_set function.

headers are not sent correctly, when session_start() is after header(...)

I didn't know about this behaviour, so I looked for the function documentation.

Here are some links that can help you understand what's going on:

http://php.net/manual/en/function.session-start.php

“Note:

This function sends out several HTTP headers depending on the configuration. See session_cache_limiter() to customize these headers.”

http://php.net/manual/en/function.session-cache-limiter.php

In fact, depending on configuration of session_cache_limiter(), using session_start() can overwrite headers "Expires", "Cache-Control" and "Last-Modified".

Hope it helps.

PHP session_cache_limiter() private and nocache HTTP Expires date question

it is the birthday of the person who contributed the code:

diffs: http://cvs.php.net/viewvc.cgi/php-src/ext/session/session.c?r1=1.80&r2=1.81

http://www.phpbuilder.com/lists/php3-list/199911/3159.php

to change it, it would be preferable to set the headers manually, for example nocache sets this:

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

but you could still do:

session_cache_limiter('nocache')
header('Expires: Thu, 1 Jan 2000 00:00:00 GMT');

header will replace any existing header with the same name (by default).



Related Topics



Leave a reply



Submit