There's an initial implementation of a download cache for ASIHTTPRequest available in this branch on github:
http://github.com/pokeb/asi-http-request/tree/downloadcache
You can download it here:
http://github.com/pokeb/asi-http-request/zipball/downloadcache
In short, there's a new ASICacheDelegate protocol that allows you to write your own cache, and the ASIDownloadCache class provides an implementation that will probably be sufficient for most people.
ASIDownloadCache caches responses for GET requests that have '200 OK' response status codes. It should work out of the box for statically served resources, but you should be able to get it to cache dynamic responses if you tweak the response headers on the server.
The body of a response is stored on disk, along with the response headers from the server. When you perform a GET request for a resource that is already cached, ASIHTTPRequest changes the request to a conditional GET request transparently. If the data in the cache is still current, requests have their response headers and body / downloadDestinationPath set to those from the cache.
Cached responses can be stored for the duration of the session, or permanently. You can also configure the cache to ignore cache-control headers from the server, and / or set your own expiry time for cached responses.
Using the download cache is easy:
[ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]];
See the options in ASICacheDelegate.h for details on how to configure the download cache to work as you want it. ASIHTTPRequests have new properties to allow you to configure how they will be cached on a per-request basis, see ASIHTTPRequest.h for more.
For certain applications, using a download cache may be enough to eliminate the need for your own local storage altogether.
I would be interested in any feedback on / bug reports for the current implementation. If all goes well, this should be in v1.7 fairly soon.
Best
Ben
--
You received this message because you are subscribed to the Google Groups "ASIHTTPRequest" group.
To post to this group, send email to
asihttp...@googlegroups.com.
To unsubscribe from this group, send email to
asihttpreques...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/asihttprequest?hl=en.