Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear cache for a URL in URLCache.shared?

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)
like image 944
Jacob Zyla Avatar asked Oct 27 '25 10:10

Jacob Zyla


1 Answers

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

like image 166
canister_exister Avatar answered Oct 29 '25 00:10

canister_exister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!