Answer the question
In order to leave comments, you need to log in
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
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.
Well, this is understandable, but how to implement it in php?
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 questionAsk a Question
731 491 924 answers to any question