Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I programmatically tell if a binary file on a website (e.g. image) has changed without downloading it?

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?

like image 508
Greg Avatar asked Sep 25 '09 18:09

Greg


3 Answers

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.

like image 173
Marc Gravell Avatar answered Nov 15 '22 01:11

Marc Gravell


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.

like image 24
xrath Avatar answered Nov 15 '22 00:11

xrath


You can do a HEAD request and check the last-modified datetime value, as well as the content-length.

like image 45
D'Arcy Rittich Avatar answered Nov 15 '22 01:11

D'Arcy Rittich