Home arrow PHP arrow Page 4 - Watching The Web

Backtracking - PHP

Ever wondered if you could be emailed automatically whenever yourfavorite Web pages changed? Our intrepid developer didn't just wonder -he sat down and wrote some code to make it happen. Here's his story.

TABLE OF CONTENTS:
  1. Watching The Web
  2. Code Poet
  3. Digging Deep
  4. Backtracking
  5. Plan B
  6. Closing Time
By: The Disenchanted Developer, (c) Melonfire
Rating: starstarstarstarstar / 7
October 23, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
So far, it looks like everything's hunky-dory - but being the suspicious character I am, I thought it might be worth trying the code out against a few servers before accepting the script above as a reliable tool. And that's when I hit my first roadblock - as it turned out, some servers didn't return the "Last-Modified" header, which meant that the script couldn't determine when the page had been last modified.

I thought this was pretty strange, as it seemed to be a violation of the rules laid down in the HTTP protocol. Back to the specification, then, to see if I could resolve this apparent conflict...

A little close reading, and the reason for the discrepancy became clear: HTTP/1.1 servers SHOULD send Last-Modified whenever feasible.In other words - they don't *have to*. And there's many a slip betwixt the cup and the lip...

OK, maybe I should have read the fine print before writing that script. Still, better late than never.

Back to the drawing board, then. After a little thought and a few carefully-posed questions to the PHP mailing lists, it seemed that my initial plan was still the most reliable - download and store the contents of each URL, and compare those contents against the previous version to see if there was any change. This wasn't the most efficient way to do it - but it didn't look like I had any alternatives.

 
 
>>> More PHP Articles          >>> More By The Disenchanted Developer, (c) Melonfire
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap

Dev Shed Tutorial Topics: