[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bkdelibs=5D_kioslave/http=3A_When_cache_mode_is_CC?=
From:       Dawit Alemayehu <adawit () kde ! org>
Date:       2011-02-21 16:01:30
Message-ID: 20110221160130.46971A609B () git ! kde ! org
[Download RAW message or body]

Git commit e1eb60c51fbb6be5e1d65d7408b50b9e2883038c by Dawit Alemayehu.
Committed on 21/02/2011 at 16:57.
Pushed by adawit into branch 'master'.

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

M  +16   -6    kioslave/http/http.cpp     

http://commits.kde.org/kdelibs/e1eb60c51fbb6be5e1d65d7408b50b9e2883038c

diff --git a/kioslave/http/http.cpp b/kioslave/http/http.cpp
index ce69c41..83431c1 100644
--- a/kioslave/http/http.cpp
+++ b/kioslave/http/http.cpp
@@ -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)) {

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic