#106 new
brad jiao

bug in ASIDownloadCache:isCachedDataCurrentForRequest

Reported by brad jiao | September 6th, 2012 @ 09:31 AM


/* if config like this:

[[ASIDownloadCache sharedCache] setShouldRespectCacheControlHeaders:NO];


[request setCachePolicy:ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy];    
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[request setSecondsToCache:60*60*24*30]; // Cache for 30 days

the "expires" will never be checked! and the isCachedDataCurrentForRequest will always be YES.

is this a bug?

// ASIDownloadCache.m line:353 in ASIDownloadCache::isCachedDataCurrentForRequest

if ([self shouldRespectCacheControlHeaders]) {

    // Look for X-ASIHTTPRequest-Expires header to see if the content is out of date
    NSNumber *expires = [cachedHeaders objectForKey:@"X-ASIHTTPRequest-Expires"];
    if (expires) {
        if ([[NSDate dateWithTimeIntervalSince1970:[expires doubleValue]] timeIntervalSinceNow] >= 0) {
            [[self accessLock] unlock];
            return YES;

    // No explicit expiration time sent by the server
    [[self accessLock] unlock];
    return NO;

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone

People watching this ticket