3

Is it possible to clear the URL Cache for just one url and not the whole cache? I have already tried this put it does not seem to do anything.

let url = URL(string: "https://example.com")!
        let request = URLRequest(url: url)
        URLCache.shared.removeCachedResponse(for: request)
Jacob Zyla
  • 225
  • 2
  • 11

1 Answers1

1

You can try make request to some url with different cache policy like reloadRevalidatingCacheData which will delete all cache for this url.

canister_exister
  • 567
  • 4
  • 15
  • Careful with this specific policy on older OS versions though: "Versions earlier than macOS 10.15, iOS 13, watchOS 6, and tvOS 13 don’t implement this constant." Use e.g. `reloadIgnoringLocalCacheData` in that case instead. – Micky Nov 09 '21 at 10:20