Commit e1eb60c5 authored by Dawit Alemayehu's avatar Dawit Alemayehu
Browse files

When cache mode is CC_Refresh (the default), ensure the expiration date of a cache is

consulated whenever a conditional GET cannot be performed.

Besides fixing bug# 104901, this improves performance by reducing unnecessary fetches
when caching is enabled.

BUG:104901
parent 15753d36
......@@ -4560,14 +4560,24 @@ QString HTTPProtocol::findCookies( const QString &url)
HTTPProtocol::CacheTag::CachePlan HTTPProtocol::CacheTag::plan(time_t maxCacheAge) const
{
//notable omission: we're not checking cache file presence or integrity
if (policy == KIO::CC_CacheOnly || policy == KIO::CC_Cache) {
return UseCached;
} else if (policy == KIO::CC_Refresh) {
return ValidateCached;
} else if (policy == KIO::CC_Reload) {
switch (policy) {
case KIO::CC_Refresh:
// Conditional GET requires the presence of either an ETag or
// last modified date.
if (lastModifiedDate != -1 || !etag.isEmpty()) {
return ValidateCached;
}
break;
case KIO::CC_Reload:
return IgnoreCached;
case KIO::CC_CacheOnly:
case KIO::CC_Cache:
return UseCached;
default:
break;
}
Q_ASSERT(policy == CC_Verify);
Q_ASSERT((policy == CC_Verify || policy == CC_Refresh));
time_t currentDate = time(0);
if ((servedDate != -1 && currentDate > (servedDate + maxCacheAge)) ||
(expireDate != -1 && currentDate > expireDate)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment