Skip to content

Commit

Permalink
Don't use the cached response if the server didn't send an explicit e…
Browse files Browse the repository at this point in the history
…xpiration time
  • Loading branch information
pjay authored and pokeb committed Nov 20, 2010
1 parent ba98423 commit b34b3f1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Classes/ASIDownloadCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ - (BOOL)isCachedDataCurrentForRequest:(ASIHTTPRequest *)request
// Look for an Expires header to see if the content is out of date
NSString *expires = [cachedHeaders objectForKey:@"Expires"];
if (expires) {
if ([[ASIHTTPRequest dateFromRFC1123String:expires] timeIntervalSinceNow] < 0) {
if ([[ASIHTTPRequest dateFromRFC1123String:expires] timeIntervalSinceNow] >= 0) {
[[self accessLock] unlock];
return NO;
return YES;
}
}
// Look for a max-age header
Expand All @@ -309,13 +309,15 @@ - (BOOL)isCachedDataCurrentForRequest:(ASIHTTPRequest *)request

NSDate *expiryDate = [[[NSDate alloc] initWithTimeInterval:maxAge sinceDate:fetchDate] autorelease];

if ([expiryDate timeIntervalSinceNow] < 0) {
if ([expiryDate timeIntervalSinceNow] >= 0) {
[[self accessLock] unlock];
return NO;
return YES;
}
}
}

// No explicit expiration time sent by the server
return NO;
}


Expand Down

0 comments on commit b34b3f1

Please sign in to comment.