Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


ASICache Performance Issue #173

myell0w opened this Issue · 2 comments

2 participants

Matthias Tretter Ben Copsey
Matthias Tretter

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?

Ben Copsey pokeb closed this issue from a commit
Ben Copsey 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)
Ben Copsey pokeb closed this in 49f75db
Ben Copsey

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

Many thanks! :)


Matthias Tretter

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
Something went wrong with that request. Please try again.