CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1

    Check whether webpage has changed?

    I have an application file that is hosted on a webserver. The client app needs to regularly check for changes to this file and download the new version. I will use the WebClient class to download the file, but I don't want to download it if it hasn't changed. It's like caching at the client application level. Is there a simple way to find out the modified date of the file programmatically through the webserver? Then I can do a quick check to see if the file has changed, and only download the updates when required.

    The fallback is to host a 2nd file which contains just the modified date or version number. The client could use WebClient to download this small file, check if that has changed, and then download the larger file, but that is extra overhead. If there is a simple way to check the date of the hosted file, then that would be preferable.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Check whether webpage has changed?

    Enterprise library has a Cache Manager that you can cache the file object (and set up a file change notification to reload a changed file if necessary). You can leverage this basic cache and wrap it to something that meets your needs (like using a token that gets passed to the client, so the client can pass the token back it to determine whether the web service should return the file).

    A bit of warning though... The Enterprise Library is significant. Fortunately, all the source code is available for you to look through, so you can easily create a slimmed down version of a component (like the Cache Manager) for your exact needs.

  3. #3

    Re: Check whether webpage has changed?

    Thanks for the reply. I ended up using the HTTPWebRequest class instead of WebClient. This allowed me to cache the date-time from the previous request, and pass it back in the IfModifiedSince Header field, so that it doesn't download if it's still the same.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured