How can I programmatically tell if a binary file on a website (e.g. image) has changed without downloading it? Is there a way using HTTP methods (in C# in this case) to check prior to fully downloading it?
Really, you want to look for the Last-Modified header after issuing a HEAD
request (rather than a GET
). I wrote some code to get the HEAD
via WebClient
here.
You can check that whether the file is changed or not by requesting with HEAD.
Then, returned response header may include Last-Modified, or ETag if the web server support.
You can do a HEAD request and check the last-modified datetime value, as well as the content-length.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With