Forum Moderators: Robert Charlton & goodroi
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); // always modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache");
When I first started with php about 7 years ago, I read that this was good as it would stop the dynamic pages from being chached - and as far as I know it has worked fine.
I am now working on my own Sitemap generator, and generating the Last Modified date from dates in a database showing when the data for that page was last edited.
Will there be a problem with this information being different to the header.
In any-case, a Last Modified date from the header of a file is going to be incorrect anyway, as the data in the database changes.
There's an outside chance Google might visit more frequently based on the misleading last-modified date, but more probably it will figure out that the date exactly matches the time of the request, and not bother doing so.
So if the present date is not put in the header, I assume the header will show the date the php file was created. Is it normal to feed a modified date from a database entry into the header to show when the page text was updated?
Is it normal to feed a modified date from a database entry into the header to show when the page text was updated?
I wouldn't say it is normal or even common to supply last-modified headers. But I would certainly say it's best practice. It saves both you and Google bandwidth to do so and IMO knowing (and supplying information on) when content was last updated is useful in a way far beyond search engines.