The iOS `URLCache` class implements the caching of responses to `URL` load requests, by mapping `NSURLRequest` objects to `CachedURLResponse` objects. This tag is a synonym of `nsurlcache`.
Questions tagged [urlcache]
7 questions
8
votes
1 answer
Using URLCache subclasses with URLSession
I have an app which uses URLSession-based networking and URLCache for storing network requests on disk. I noticed that when the storage size of URLCache reaches the diskCapacity, the eviction strategy seems to be to remove all entries, which is a…

Nikita Zhuk
- 151
- 7
6
votes
0 answers
How is cached data validated with `reloadRevalidatingCacheData`?
A URLRequest allows a cache option where cached data is revalidated with the origin by setting the option .reloadRevalidatingCacheData.
The docs say:
Use cache data if the origin source can validate it; otherwise, load
from the origin.
I assume…

Manuel
- 14,274
- 6
- 57
- 130
2
votes
3 answers
WKWebView doesn't use URLCache
I have an application which use UIWebView to show some local content. I Also have a custom URLCache to intercept requests and replace them with local content:
class LocalWebViewCache: URLCache {
open override func cachedResponse(for request:…

mehdok
- 1,499
- 4
- 29
- 54
1
vote
0 answers
URLSession and URLCache not working as expected
For a GET request which is consistently the same (it has a query param too), I'm returning in the response this response header.
Cache-Control: max-age=3600, private
I'm creating a URLSession with this configuration. Basically, ensuring my cache is…

bandejapaisa
- 26,576
- 13
- 94
- 112
1
vote
0 answers
Retrieve path instead of data to cached response from URLCache
I want to retrieve the data from a cached URLResponse as a local URL or path instead of the Data object in memory.
Is this possible? I know that URLCache puts its data inside a Cache.db file somewhere...
Background: I want to use URLCache as my…

heyfrank
- 5,291
- 3
- 32
- 46
0
votes
0 answers
URLCache not caching 404 response
My server is sending proper cache headers, however URLSession will not cache the response. Is there any way to make it cache, although it is a 404?
HTTP/1.1 404 Not Found
Content-Type: application/json; charset=utf-8
Cache-Control: public,…

Mick
- 954
- 7
- 17
0
votes
0 answers
Swift: How remove Cashed Responses from URLCache by date
What I'm try to do?
Remove existing responses in URLCache prior a given date.
How I try to do that?
removeCachedResponses(since: date)
func resetCache(_ since: Date) {
self.cache.removeCachedResponses(since: since)
}
Cashed responses…

rotecodefraktion
- 259
- 2
- 9