0
votes

I have setup an NSURLCache and set the sharedcache to the initialized cache.

I can see the cache size growing when I log the size in the NSURLConnection delegates.

For some reason when requesting the same data, a request is made to the server again, and the log of the cache size shows the log staying the same size.

This indicates to me that the cache is working correctly, but for some reason the URL Loader is not pulling from the cache.

I use the default cache policy on the requests and have double checked the headers in the response.

After reading around on here I see other people mentioning the same issue and setting the memory capacity and disk capacity to the same value solves their issue, but it does not work for me. New requests are being made every time rather than pulling from the cache.

Would it be wise to instead check the cache for the data before making the request? I dont see the point of the cachingPolicy parameter to the NSURLRequest method.

1
By chance does your URL have a query string?AlBeebe
@AlBeebe Thanks, yes it does have a query string. How would it effect the cache?some_id
it wont cache automaticalllyDaij-Djan
I see the cache size growing. How does one see what is in the cache itself? So I should override the caching delegate method for writing and check for the object in cache for reading instead of relying on the caching policy?some_id
I don't think it will cache if you use a query string. Do a quick test to see if it caches the response when you don't pass a query string. Maybe its possible your query string keeps changing each time you make a request for instance if one of the parameters is say the time.AlBeebe

1 Answers

0
votes

well HTTP also lets the server tell you how to cache - it can disallow caching (and also set a max. cache time)

that may influence SDURLCache


anyways, also look at UIWebView and NSURLCache have a troubled relationship

there it is said that UIWebView doesnt work