Delegate method for when caching logic is running without server cues
| Originator: | daniel | ||
| Number: | rdar://11541572 | Date Originated: | 5/26/2012 |
| Status: | Closed | Resolved: | Yes |
| Product: | Developer Tools | Product Version: | iOS 5.1/OS X 10.7.4 |
| Classification: | Enhancement | Reproducible: | N/A |
26-May-2012 05:54 PM Daniel Pasco: Summary: When NSURLRequestUseProtocolCachePolicy is used for an NSURLRequest (the default), the frameworks use an apparently undocumented, very long-lived caching policy if expiration details are not explicitly provided by the server. It would be very nice in this situation if a delegate method on NSURLConnection could be used to communicate to the app that it will be caching the data without server guidelines. In some cases it may be better for the application to disable caching and fetch data directly. This would be preferable to disabling local caching through the use NSURLRequestReloadIgnoringLocalCacheData, since that would totally ignore it when servers provide valid expiration information and could potentially result in a very large amount of server traffic. This could conceivably be done by decorating the NSCachedURLResponse passed to the - (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse with expiration information. Steps to Reproduce: N/A Expected Results: N/A Actual Results: N/A Regression: N/A Notes: We recently shipped an application using NSURLRequestUseProtocolCachePolicy. The server was not configured to provide expiration information in its response headers and users ended up missing time-critical events.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
There is sufficient information contained in - connection:willCacheResponse: to make this determination. See http://blackpixel.com/blog/1659/caching-and-nsurlconnection/ for details