Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2001

    script to check and download a file if newer or changed

    I'd like to do this automatically, but will settle for a manual "check for updates" submit button approach

    The site has a "picture of the day" which is usually, but not always, changed daily. The web page is close to a full screen display of that picture.

    If a user clicks on "check for updates" and there are none (ie the picture on the site is the same as the picture in their cache), then there should be no refresh. It seems to me that it should be possible just to check the file size and ?date of the pic on the server and compare it to the same details of the file in the cache, and only initiate a download if the server side file is newer.


  2. #2
    Join Date
    Jul 2003
    You cannot search/modify/see the users cache -- unless you write a special IE ActiveX control, and your user agrees to install it.

    Best way to avoid this problem -- use a caching template engine.

    You can, however, set some caching headers and see if that helps.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  3. #3
    are a couple solutions...

    most of the time browsers will do this automatically... but anyway.. if you dont know php this will all be jiberish to you..

    you can use headers to tell the browser to see if it's new or old...

    header('Cache-Control: post-check=1, pre-check=1', TRUE);

    and another solution is to use the md5_file() function to set a cookie on the user's computer and then when they goto the image page md5_file() the file on the server with the md5_file() value in the user's cookie and if they are the same..... you cant really just load it from the user's computer this way though.. you could put "you have already seen this picture would you like to re-download it?" ensted of the picture and then when it said that it would link to "picoftheday.php?v=1" or something and then it would show the picture no matter what...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts