Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSURLCache and ETags

Does NSURLCache transparently handle ETags received by server?

I mean: does it automatically store ETags for each URL request and then send the appropriate If-None-Match when a request to the same URL is submitted? Or do I have to manage it by myself?

like image 898
Sirio Avatar asked Feb 09 '14 13:02

Sirio


1 Answers

yes it does handle it transparently if you set its cache mode:

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]
                                                           cachePolicy: NSURLRequestUseProtocolCachePolicy
                                                       timeoutInterval:60];

note: you cannot see the header in the request at all and if a 304 response is returned by the server you will only see the 200 response that it transparently loaded from the cache.

like image 168
Daij-Djan Avatar answered Oct 09 '22 01:10

Daij-Djan