When I use the following, javascript:alert(document.lastModified), in Chrome to check whether my site was updated, the alert dialog box appears, but there is no content within the box. My page is powered by PHP, therefore it should display the time and date of page request should it not?
Asked
Active
Viewed 2,997 times
1 Answers
0
PHP-generated pages don't have last-modified dates. They're dynamically generated, so by definition their last-modified data is "now", regardless of how much dynamic data is actually served, or if the output hasn't changed since the last time. You'd have to set a last-modified header yourself, using header()
.

Marc B
- 356,200
- 43
- 426
- 500
-
What about ASP pages then? They are also server-generated aren't they? Yet they display last-modified information. – happy Sep 12 '11 at 17:45
-
Completely different environment/language. – Marc B Sep 12 '11 at 17:46
-
but it is server generated though, the time displayed is the current time and date. Oh well! Thanks for your help. – happy Sep 12 '11 at 17:47
-
@happy: ASP.NET does a lot more on your behalf than PHP does. afaik, unless you tell it otherwise using `header()`, PHP generates the `HTTP/1.1 200 OK\n` header and `Content-Type: text/html\n\n` header and that's it... although the web server may add a few additional headers of its own. – Powerlord Sep 12 '11 at 18:04