arnoapp
arnoapp

Reputation: 2506

Recognize changes in files

my app checks a website for some files with simple NSURLConnection Method. Now I want to recognize if one of the files has changed without downloading the file and compare it.

I thought about md5 checksums but how can I do this without wasting traffic downloading the whole file.

Do you have any ideas for this?

Upvotes: 0

Views: 129

Answers (1)

Mattia
Mattia

Reputation: 2281

Check the timestamp on the file. That should be easier then using md5 checksums. I don't know how your app or or server API is implemented but the idea is pretty straightforward:

  • On the server create an API that allows you to query when a file was last modified (keeping track of the modification timestamps should already be handled by the OS on the server)
  • When you download the file on your client also store the timestamp (i.e. when the server thinks the file was last modified).
  • When checking whether to update a file, first ask the server timestamp for the file and compare it with the one in your client app - if the server timestamp is more recent than the one on your client download the new file, otherwise do nothing.

Upvotes: 2

Related Questions