0

Before I continue writing my own infrastructure - is it possible to execute a request, have it return immediately if it's cached, and then return later if the cached version does not match the current version? Is that kind of functionality built-in to NSURLCache/NSURLRequest?

In other words:

  • request MYTHING.json
  • return immediately with cached MYTHING.json
  • display to user
  • return again if the cached version was not current
  • update display
xtravar
  • 1,321
  • 11
  • 24

1 Answers1

0

You can query NSURLCache directly via cachedResponseForRequest: to find out whether anything is already in it. You can then issue the NSURLRequest and see whether what comes back is different. But I'm not aware of a built-in mechanism that would give you first anything that's already in the cache then whatever is fetched, if it determines that anything needs to be fetched and if what was fetched is different.

Tommy
  • 99,986
  • 12
  • 185
  • 204