Search code examples
iosobjective-ccachingafnetworkingnsurl

iOS: Are there any issues that can occur when setting cache policy to no?


I don't want my App storing any URL data in the cache.db file. I took advice on StackOverflow and set the cache URL policy to NSURLRequestReloadIgnoringLocalCacheData like this.

[manager.requestSerializer setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];

However, I'm not sure if there are any issues that can arise from doing this. Any tips or suggestions are appreciated.

Edit: I haven't ran into any issues regarding requests or the App in general, but I like to make sure.


Solution

  • There won't be any issues with this, however you have to ensure, that the named behaviour is really the one you want. E.g. you have a caching mechanism implemented somewhere else.

    This policy does exactly what is supposed to do. It ignores any local cache data and loads any data directly from a remote source. However, you're not protected from any intermediate caching mechanisms.

    You can include proper headers to your request to omit any intermediate caching (Cache-Control: no-cache to tell some proxies what do you want to do with the request for example)