How to get a site's Last-modifed date?

When it come to PHP (and similar) sites it’s probably the only reliable way if the server is not actually serving you with the information.
As you well know any one “page” is typically not the ouput of a single PHP file but could be calling any number of classes, templates, controllers, bits of html content, database tables, etc, etc, that could all have been modified at any time with the entry point (which may be the only client accessible part) knowing nothing about it.
And just how do you define modified?
A refactor of a function to produce the exact same output (a little more efficiently maybe) will change the last-modified of the containing file, but not alter the content of the page.
As far as the client side is concerned (which is all you really have as a client) I would probably go by any change to actual content in the absence of a provided time.

3 Likes

It was years ago, sorry to say I can’t remember. I was only testing against one site, it was a download site for a product we were using, and as updates were quite frequent in the run-up to a release I was getting fed up of checking manually every day.

As I recall it was something in the request header from my client rather than me checking the modified date that came back - I kept a note of the date/time I last checked, sent that over in the GET, and was surprised that it always thought the page had changed. But as the page always contained the server date/time as part of the general site layout, the server software decided that active content meant the page had changed.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.