Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does NSURLRequestReloadIgnoringLocalAndRemoteCacheData work in iOS 7?

Good evening! I'm hoping someone out there can help me out with a problem I'm seeing.

Ever since iOS 7 was rolled out the following call does NOT work:

NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60];

Whenever I update the page pointed to by url above it pulls old content - even if I reboot the device. This problem is seen by multiple (all maybe) users of my app.

Something changed between iOS 6 and iOS 7. Does anyone have any pointers on how to reliably pull a remote file (HTML in this cases) while ignoring any and all caches? Seems like the way I WAS using is not longer working/supported.

Thank you!

like image 726
Mr. Spock Avatar asked Nov 03 '13 23:11

Mr. Spock


2 Answers

According to the NSURLRequest headers, NSURLRequestReloadIgnoringLocalAndRemoteCacheData is unimplemented, so I wouldn't rely on it. You may want to use NSURLRequestReloadIgnoringLocalCacheData and try to avoid the server cache on your server side.

enum
{
    NSURLRequestUseProtocolCachePolicy = 0,

    NSURLRequestReloadIgnoringLocalCacheData = 1,
    NSURLRequestReloadIgnoringLocalAndRemoteCacheData = 4, // Unimplemented
    NSURLRequestReloadIgnoringCacheData = NSURLRequestReloadIgnoringLocalCacheData,

    NSURLRequestReturnCacheDataElseLoad = 2,
    NSURLRequestReturnCacheDataDontLoad = 3,

    NSURLRequestReloadRevalidatingCacheData = 5, // Unimplemented
};
typedef NSUInteger NSURLRequestCachePolicy;
like image 177
Marcelo Fabri Avatar answered Oct 20 '22 03:10

Marcelo Fabri


I ended up having to use the "timestamp" solution found in this post:

NSURLConnection is returning old data

like image 40
Mr. Spock Avatar answered Oct 20 '22 05:10

Mr. Spock