Note that there are some explanatory texts on larger screens.

plurals
  1. PONSURLConnection Sticky Cache
    primarykey
    data
    text
    <p>I'm having an issue with a sticky cache when using NSURLConnection. I create a NSMutableURLRequest using the following line:</p> <pre><code> NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60]; [request setHTTPMethod:@"POST"]; [request setValue:@"text/javascript,application/json,application/javascript;q=0.9,*/*;q=0.8" forHTTPHeaderField:@"Accept"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody: requestData]; </code></pre> <p>I then make the connection like so:</p> <pre><code>NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self]; </code></pre> <p>On the surface everything works fine, it connects and pulls in the json object the server sends it's way. If I update the json object on the server so it contains another node and then via the App have it request the url like above, it returns a cached version of the json object. As proven by outputting the received data in </p> <pre><code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection </code></pre> <p>I've tried to add a timestamp to the requested url but still received the cached version. I am resetting the receivedData var to nil before each request and reinit the var on connection:didReceiveData: but still getting the cached version.</p> <p>I even set up a delegate method to force no cache:</p> <pre><code>- (NSCachedURLResponse *) connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse{ return nil; } </code></pre> <p>EDIT: I verified the changed response by hitting the requested URL in a browser, but even after that the app still uses the cached data.</p> <p>So my question is how can I completely destroy the cache? </p> <p>Thanks, Bruce</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload