Questions tagged [nsurlrequestcachepolicy]

Specifies the caching behavior of the request

NSURLRequest has a cachePolicy property, which specifies the caching behavior of the request according to these constants:

  • NSURLRequestUseProtocolCachePolicy;
  • NSURLRequestReloadIgnoringLocalCacheData;
  • NSURLRequestReloadIgnoringLocalAndRemoteCacheData;
  • NSURLRequestReturnCacheDataElseLoad
  • NSURLRequestReturnCacheDataDontLoad;
  • NSURLRequestReloadRevalidatingCacheData.

Sources

25 questions
10
votes
1 answer

How to get cached responses using Alamofire while app is in offline?

After I got a response via Alamofire, in some cases, implementing a database or managing local storage myself (file etc.) can be a bit overkill. I know about Alamofire's requestCachePolicy and it is already caching responses (based on…
Jakub Truhlář
  • 15,319
  • 7
  • 65
  • 73
4
votes
0 answers

NSURLCache not working after iOS app termination

I am building an app in which I am implementing offline mode as well. For this I used NSURLCache mechanism. When the app is in foreground then the cache mechanism works perfectly even if the device goes in offline mode. The problem comes when I quit…
4
votes
3 answers

NSURLRequest cache issue iOS 7

in iOS 7 cachePolicy doesn't work, it just cache the downloaded json. //URLRequest NSString *url = [NSString stringWithFormat:@"http://www.semhora.com/jsonparser/categories/categories_%d_test.json", _categoriesIndex]; NSURLRequest…
Marckaraujo
  • 7,002
  • 11
  • 50
  • 92
3
votes
1 answer

UIWebView strange behavior with cache policy

I'm having this problem with UIWebView: Customer asked to check the cache policy of our UIWebView because, according to him, content updated on the server didn't appear on the device when reloading a page. Now, I saw that the NSURLRequest that we're…
Vik
  • 1,877
  • 12
  • 18
1
vote
0 answers

How to configure URLSessionConfiguration so that cached data lasts only 5 minutes (Backend doesn't handle expiration time)

I would like to cache the data I am receiving from my API requests. More precisely, I would like a 5 - 10 minutes maximum lifetime for my cache data. Indeed, I am working on a weather app and I don't need database, but just to be able to reuse data…
1
vote
1 answer

is network cache stays after iOS application is removed and reinstall

I have an iOS application that fetches network resources by using URLRequest with default cachePolicy. I would like to know if: When the application is deleted from my device, is all cached responses are removed as well? Or do they stay somewhere…
Duyen-Hoa
  • 14,296
  • 4
  • 30
  • 40
1
vote
1 answer

(iOS bug?) NSURLRequest cached authorization passes with incorrect credentials

I'm wondering that NSURLRequest with .returnCacheDataElseLoad/.returnCacheDataDontLoad cache policy ignores basic authorization. So the following scenario works incorrectly: Set up URL cache policy to use local cache prior to requesting to…
brigadir
  • 6,123
  • 4
  • 44
  • 76
1
vote
1 answer

NSURLRequestCachePolicy.UserProtocolCachPolicy requirements

I am using the following code for caching, the response received form the server has the following headers. Is there any header that needs to be set from the request side, for the caching to work for 10 seconds of age. Connection Received…
NNikN
  • 3,322
  • 5
  • 38
  • 74
1
vote
1 answer

How does [NSURLCache cachedResponseForRequest:] do its matching?

How does NSURLCache determine that it has a cached response for a request? It's not clear to me how equality between two NSURLRequests is defined or how they are hashed.
Ben Flynn
  • 17,294
  • 18
  • 92
  • 133
1
vote
0 answers

iOS Cache Policy behaviour UIWebView

I am using a UIWebview and load a NSMutableURLRequest into it: NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:initialURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10.0]; [_webview loadRequest:req]; This…
ilmgb
  • 780
  • 4
  • 20
1
vote
1 answer

NSMutableURLRequest setCachePolicy is not used

I have an NSURLMutableURLRequest where I call [urlRequest setCachePolicy:NSURLRequestReloadRevalidatingCacheData]; When I po [urlRequest cachePolicy] it is always 1. What is the getter doing that could force it to return 1?
cynistersix
  • 1,215
  • 1
  • 16
  • 28
0
votes
1 answer

NSURLCACHE policy to update cache data if website is reachable and so always load cache

I'm totally new to swift and iOS development. I'm trying to do a webview app and i need to update the cache because the website can change but i also need to be able to access it while offline. Is there any premade cache policy i can use in order to…
0
votes
1 answer

Expiration of CachedURLResponse not working

I was trying to set custom headers for 'Cache-Control' to achieve a cache at client side(server side has 'Cache-Control: no-cache'). Trying to achieve following two major things. Response of some of the end points should be cached in memory…
0
votes
0 answers

Which Cache Policy should be used?

My data is retrieve from a JSON API, and the data would changed per day. Currently, i'm using reloadIgnoringLocalCacheData now, which ignores the cache data and always retrieve data from the originating source. My question is that could I just…
ChuckZHB
  • 656
  • 2
  • 15
0
votes
1 answer

IOS - WKWebview gets null url in decidePolicy when second clicking the same button

I have a WKWebview with a button that downloads a pdf, the button link is as follows: I…
1
2