I have problem implementing caching using AFNetworking and ETag values. My server returns Cache-Control and ETag headers values for every request. But if I make a second request for the same resource AFNetworking won't add ETag. Should I manually save etag for each response I got and append it to next requests?
In app delegate I have set cache object:
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
[NSURLCache setSharedURLCache:URLCache];
Also, I'm using default cache policy of AFHTTPRequestSerializer.
Any ideas what is the problem? Maybe I don't understand the idea of http caching. As far as I know it should be transparent, and all I have to do is to attach ETag and Cache-Control headers for every response.
EDIT:
The headers of response looks like this:
"Cache-Control" = "max-age=3600";
"Content-Encoding" = gzip;
"Content-Type" = "application/json; charset=utf-8";
Date = "Wed, 05 Aug 2015 07:52:33 GMT";
Etag = "W/f6c8a0f47deb7db0eeea3069061de9ab";
Expires = "Wed, 05 Aug 2015 08:52:30 GMT";
"Last-Modified" = "Wed, 05 Aug 2015 08:52:30 GMT";
Server = "cloudflare-nginx";
Vary = "Accept-Encoding";
"cf-ray" = "2110ec564bde0afc-WAW";
"x-cache-id" = "api_3447fddb8680ed5d082ae871e95214dc";
"x-powered-by" = "PHP/5.5.19";
"x-whom" = "www-stage02-b"