Title: [170949] trunk/Source/WebCore
Revision
170949
Author
commit-qu...@webkit.org
Date
2014-07-09 20:11:26 -0700 (Wed, 09 Jul 2014)

Log Message

[Curl] Cache entry invalidated too early.
https://bugs.webkit.org/show_bug.cgi?id=134681

Patch by pe...@outlook.com <pe...@outlook.com> on 2014-07-09
Reviewed by Alex Christensen.

When a cache entry has expired, it is invalidated when a request for the corresponding url is started.
This is too early, since the resource is possibly not modified (even though it has expired),
and the server might respond with a 304 (not modified) response.
When we then receive a 304 response, the cache entry is deleted, and we have no cached response/data to provide.
This can be solved by not invalidating the entry when a request for that url is started,
but instead invalidate when a 200 OK response is received (which means the resource has been modified).

* platform/network/curl/CurlCacheManager.cpp:
(WebCore::CurlCacheManager::isCached): Avoid invalidating cache entry when it has expired, wait until we know the server response.
* platform/network/curl/CurlCacheManager.h: Added const modifier.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (170948 => 170949)


--- trunk/Source/WebCore/ChangeLog	2014-07-10 02:18:30 UTC (rev 170948)
+++ trunk/Source/WebCore/ChangeLog	2014-07-10 03:11:26 UTC (rev 170949)
@@ -1,3 +1,21 @@
+2014-07-09  pe...@outlook.com  <pe...@outlook.com>
+
+        [Curl] Cache entry invalidated too early.
+        https://bugs.webkit.org/show_bug.cgi?id=134681
+
+        Reviewed by Alex Christensen.
+
+        When a cache entry has expired, it is invalidated when a request for the corresponding url is started.
+        This is too early, since the resource is possibly not modified (even though it has expired),
+        and the server might respond with a 304 (not modified) response.
+        When we then receive a 304 response, the cache entry is deleted, and we have no cached response/data to provide.
+        This can be solved by not invalidating the entry when a request for that url is started,
+        but instead invalidate when a 200 OK response is received (which means the resource has been modified).
+
+        * platform/network/curl/CurlCacheManager.cpp:
+        (WebCore::CurlCacheManager::isCached): Avoid invalidating cache entry when it has expired, wait until we know the server response.
+        * platform/network/curl/CurlCacheManager.h: Added const modifier.
+
 2014-07-09  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Revert r170413 and r170390

Modified: trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp (170948 => 170949)


--- trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2014-07-10 02:18:30 UTC (rev 170948)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2014-07-10 03:11:26 UTC (rev 170949)
@@ -236,18 +236,15 @@
         it->value->didFinishLoading();
 }
 
-bool CurlCacheManager::isCached(const String& url)
+bool CurlCacheManager::isCached(const String& url) const
 {
     if (m_disabled)
         return false;
 
     auto it = m_index.find(url);
-    if (it != m_index.end()) {
-        if (it->value->isCached())
-            return !it->value->isLoading();
+    if (it != m_index.end())
+        return it->value->isCached() && !it->value->isLoading();
 
-        invalidateCacheEntry(url);
-    }
     return false;
 }
 

Modified: trunk/Source/WebCore/platform/network/curl/CurlCacheManager.h (170948 => 170949)


--- trunk/Source/WebCore/platform/network/curl/CurlCacheManager.h	2014-07-10 02:18:30 UTC (rev 170948)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheManager.h	2014-07-10 03:11:26 UTC (rev 170949)
@@ -45,7 +45,7 @@
     const String& cacheDirectory() { return m_cacheDir; }
     void setStorageSizeLimit(size_t);
 
-    bool isCached(const String&);
+    bool isCached(const String&) const;
     HTTPHeaderMap& requestHeaders(const String&); // Load headers
     bool getCachedResponse(const String& url, ResourceResponse&);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to