ASICache Performance Issue #173

myell0w opened this Issue Apr 26, 2011 · 2 comments


None yet

2 participants

myell0w commented Apr 26, 2011

I found that loading from the cache takes a long time, longer than it should be. I initialized the cache-relevant part of my request like this:

[request setDownloadCache:[ASIDownloadCache sharedCache]];
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[request setSecondsToCache:MTTimeIntervalDays(7)];
[request setCachePolicy:ASIAskServerIfModifiedWhenStaleCachePolicy];

I did a quick profiling with Instruments and it tells me that the following calls are the bottleneck:

[ASIDownloadCache canUseCachedDataForRequest:]
  |_  [ASIDownloadCache isCachedDataCurrentForRequest:]
            |_ [ASIHTTPRequest dateFromRFC1123String:]

Image of the call-tree from Instruments:

Any suggestions?

@pokeb pokeb added a commit that closed this issue May 7, 2011
@pokeb Rework expiry handling in ASIDownloadCache:
All requests now store a single expiry timestamp constructed from either secondsToCache, a cache-control: max-age header, or an expires header (in order of precedence)
This is used for all expiry checks, and should speed up checking if cached data is stale because it elimiates the need for NSDateFormatter or NSScanner when reading from the cache
(closes gh-173)
@pokeb pokeb closed this in 49f75db May 7, 2011
pokeb commented May 7, 2011

I've made some internal changes to ASIDownloadCache to remove the need for the NSDateFormatter, so hopefully this should speed things up.

Many thanks! :)


myell0w commented May 7, 2011

Thank you, performance is much better now when loading from cache!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment