Forum Moderators: phranque

Message Too Old, No Replies

PHP/Apache and the If-Modified-Since HTTP header

         

HoboTraveler

2:40 pm on Nov 20, 2007 (gmt 0)

10+ Year Member



Hi All,

I read on the google webmaster guidelines that the server needs to support the If-Modified-Since HTTP header.

I guess the If-Modified-Since HTTP header would work for static pages only.

I generate PHP dynamic content from the database. In this case a real file does not exist. I guess the If-Modified-Since HTTP header would not work in the case of dynamic pages?

How would google know if the content on PHP generated pages is updated?

Is it possible for PHP to trigger the If-Modified-Since HTTP header?

TIA

jdMorgan

3:58 pm on Nov 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The client (browser or SE robot) sends a request, saying "send me the object If-Modified-Since" followed by a timestamp indicating the last time the client fetched that object.

You server (or in the case of dynamic sites, your script) should then check to see when the content of that object was last changed.

If the content has been changed after the date sent by the client, the server (or your script) should return the content-body of the new object, along with a 200-OK status response.

If the content has not been changed after the date sent by the client, the server (or your script) should return no content-body, and send a 304-Not Modified status response instead of the 200-OK.

When using a script, you have the option to send 304-Not Modified if only minor unimportant changes have been made to the page. This can save you a lot of bandwidth. The SE robots like to use this method because in addition to saving them bandwidth, it also prevents them from having to waste time parsing, ranking, and updating the search results for pages which have not actually changed.

There are many many ways to make your script support the Not-Modified protocol. The best way depends on how your pages are generated, and what method you use to decide what you want to call a page modification.

Jim