• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Don't cache my NSURLResponse
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Don't cache my NSURLResponse


  • Subject: Don't cache my NSURLResponse
  • From: Glen Simmons <email@hidden>
  • Date: Thu, 24 Nov 2005 09:37:38 -0600

I'm converting XHTML to an NSAttributedString using - initWithData:options:documentAttributes:error:. There are img tags in the XHTML that look like this:
<img src="foo://0.png"/>
The image data is in my data model, so I'm using a subclass of NSURLProtocol to supply it. This is working fine until I load a different bit of XHTML that also happens to have an img tag with the same URL. It's actually a different image, but the framework is apparently caching the data for that URL b/c I don't get called and the first image shows up. My NSURLProtocol subclass' -startLoading method looks like this:


    id<NSURLProtocolClient> client = [self client];
    NSURLRequest*           request = [self request];
    NSString*               mimeType = @"image/png";
    NSData*                 data;

data = [dataProvider generateDataForRequest:request];
if (data && mimeType) {
NSURLResponse *response = [[NSURLResponse alloc] initWithURL: [request URL]
MIMEType:mimeType
expectedContentLength:-1
textEncodingName:nil];
[client URLProtocol:self
didReceiveResponse:response
cacheStoragePolicy:NSURLCacheStorageNotAllowed];
[client URLProtocol:self didLoadData:data];
[client URLProtocolDidFinishLoading:self];
[response release];
} else {
int resultCode;


        resultCode = NSURLErrorResourceUnavailable;

[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:resultCode userInfo:nil]];
}


Notice that I'm passing NSURLCacheStorageNotAllowed to - URLProtocol:didReceiveResponse:cacheStoragePolicy:, but it's still caching. Suggestions?

Thanks,
Glen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Cross platform development: Was: Deprecated methods in NSDocument
  • Next by Date: Re: Launch older app
  • Previous by thread: Cant remove ColorSyncProfile
  • Next by thread: Glyphs displayed in a bad direction
  • Index(es):
    • Date
    • Thread