How do I invalidate iOS's cache for a particular URL?

后端 未结 3 1836
[愿得一人]
[愿得一人] 2021-01-03 00:54

Using NSURLSession\'s default caching, how do I invalidate the cache for a particular URL?

I note NSURLCache\'s removeCachedResponseF

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 01:27

    The solution turns out not to be invalidating the cache for an existing URL, but to set:

    request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;

    When you make the next request for the resource you know to be invalid. There are options to ignore the local cache only, or to request that upstream proxies ignore their caches too. See the NSURLRequest/NSMutableURLRequest documentation for details.

提交回复
热议问题