1

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?

Lorenzo B
  • 33,006
  • 23
  • 110
  • 185
cynistersix
  • 1,215
  • 1
  • 16
  • 28

1 Answers1

1

I suppose that this policy has not been implemented yet (navigate NSURLMutableURLRequest by means of cmd+click and find NSURLRequestCachePolicy).

enum
{
    NSURLRequestUseProtocolCachePolicy = 0,

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

    NSURLRequestReturnCacheDataElseLoad = 2,
    NSURLRequestReturnCacheDataDontLoad = 3,

    NSURLRequestReloadRevalidatingCacheData = 5, // Unimplemented
};
typedef NSUInteger NSURLRequestCachePolicy;

This is also well documented in NSURLCache. There is also a radar at http://openradar.appspot.com/radar?id=1755401.

Lorenzo B
  • 33,006
  • 23
  • 110
  • 185
  • The policy still isn't working for my UIWebView using NSURLRequestReturnCacheDataElseLoad. The UIWebView returns 2 for the first request inside shouldStartLoadWithRequest for the request cachePolicy but subsequent requests return 1 for the cachePolicy – cynistersix Jun 26 '13 at 01:07