S
S
Silentium20152015-10-20 15:51:39
PHP
Silentium2015, 2015-10-20 15:51:39

Last-modified how to set up?

How can I set up Last-modified so that it is updated once a day on the main page, once a week on the internal ones?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Neocaridina, 2015-10-20
@Neocaridina

Once a day - display the current date with the current day/month/year but with a static time. + checking for a time in the future or stupidly 00:00:01 GMT. Or within a small random, depending on the current day / day of the week ...
On the internal it's the same, just hook on to the day of the week.
ps:
It's safer to just put the necessary lastmod in the sitemap.

S
Silentium2015, 2015-10-20
@Silentium2015

Well, this is understandable, but how to implement it in php?

R
Roman Shilin, 2015-12-11
@flexdrayv

PHP implementation
The code returns the correct LastModified header of the server response.
//DATE Modified
$date = new DateTime("2015-12-10"); // last time the page was modified
$LastModified_unix = $date->format("U");
$LastModified = gmdate("D, d MYH:i:s \G\M\T", $LastModified_unix);
$IfModifiedSince = false;
if (isset($_ENV['HTTP_IF_MODIFIED_SINCE']))
$IfModifiedSince = strtotime(substr($_ENV['HTTP_IF_MODIFIED_SINCE'], 5));
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
$IfModifiedSince = strtotime(substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 5));
if ($IfModifiedSince && $IfModifiedSince >
exit;
}
header('Last-Modified: '. $LastModified);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question