Title: [181734] trunk
Revision
181734
Author
[email protected]
Date
2015-03-19 00:54:06 -0700 (Thu, 19 Mar 2015)

Log Message

The network cache should ignore "cache-control: no-cache, must-revalidate" on history navigation
https://bugs.webkit.org/show_bug.cgi?id=142831
<rdar://problem/20209957>

Reviewed by Antti Koivisto.

Source/WebKit2:

The network cache should ignore "no-cache" and "must-revalidate" as
Cache-Control policy for history navigations to avoid unnecessary
revalidation in this case. Our memory cache already behaves this way.

On history navigation, our disk cache implementation currently
revalidates unconditionally resources if "cache-control: no-cache" is
used. It also revalidates expired resources if "cache-control:
must-revalidate" is used. This is sub-optimal.

RFC 7234 does not require us to do so [1]:
"""
  User agents often have history mechanisms, such as "Back" buttons and
  history lists, that can be used to redisplay a representation
  retrieved earlier in a session.

  The freshness model (Section 4.2) does not necessarily apply to
  history mechanisms.  That is, a history mechanism can display a
  previous representation even if it has expired.
"""

Chrome and IE9+ [2] already ignore "cache-control: must-revalidate" on history navigation.

[1] https://tools.ietf.org/html/rfc7234#page-32
[2] http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx

Test: http/tests/cache/disk-cache-validation-back-navigation-policy.html

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::decodeStorageEntry):

LayoutTests:

Rebaseline disk-cache-validation-back-navigation-policy.html test now
that we ignore "cache-control: no-cache, must-revalidate" on history
navigation. This is a progression.

* http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181733 => 181734)


--- trunk/LayoutTests/ChangeLog	2015-03-19 06:30:11 UTC (rev 181733)
+++ trunk/LayoutTests/ChangeLog	2015-03-19 07:54:06 UTC (rev 181734)
@@ -1,3 +1,17 @@
+2015-03-19  Chris Dumez  <[email protected]>
+
+        The network cache should ignore "cache-control: no-cache, must-revalidate" on history navigation
+        https://bugs.webkit.org/show_bug.cgi?id=142831
+        <rdar://problem/20209957>
+
+        Reviewed by Antti Koivisto.
+
+        Rebaseline disk-cache-validation-back-navigation-policy.html test now
+        that we ignore "cache-control: no-cache, must-revalidate" on history
+        navigation. This is a progression.
+
+        * http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt:
+
 2015-03-18  Brent Fulgham  <[email protected]>
 
         [Win] Windows gardening for debug bots.

Modified: trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt (181733 => 181734)


--- trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt	2015-03-19 06:30:11 UTC (rev 181733)
+++ trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt	2015-03-19 07:54:06 UTC (rev 181734)
@@ -24,13 +24,13 @@
 response source: Network
 
 response headers: {"Cache-control":"no-cache"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=0, no-cache"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=100, no-cache"}
-response source: Network
+response source: Disk cache
 
 response headers: {"ETag":"match"}
 response source: Disk cache
@@ -51,13 +51,13 @@
 response source: Network
 
 response headers: {"Cache-control":"no-cache","ETag":"match"}
-response source: Disk cache after validation
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=0, no-cache","ETag":"match"}
-response source: Disk cache after validation
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=100, no-cache","ETag":"match"}
-response source: Disk cache after validation
+response source: Disk cache
 
 response headers: {"ETag":"nomatch"}
 response source: Disk cache
@@ -78,19 +78,19 @@
 response source: Network
 
 response headers: {"Cache-control":"no-cache","ETag":"nomatch"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=0, no-cache","ETag":"nomatch"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=100, no-cache","ETag":"nomatch"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"must-revalidate"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=0, must-revalidate"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=100, must-revalidate"}
 response source: Disk cache
@@ -105,19 +105,19 @@
 response source: Network
 
 response headers: {"Cache-control":"no-cache, must-revalidate"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=0, no-cache, must-revalidate"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=100, no-cache, must-revalidate"}
-response source: Network
+response source: Disk cache
 
 response headers: {"ETag":"match","Cache-control":"must-revalidate"}
-response source: Disk cache after validation
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=0, must-revalidate","ETag":"match"}
-response source: Disk cache after validation
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=100, must-revalidate","ETag":"match"}
 response source: Disk cache
@@ -132,19 +132,19 @@
 response source: Network
 
 response headers: {"Cache-control":"no-cache, must-revalidate","ETag":"match"}
-response source: Disk cache after validation
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=0, no-cache, must-revalidate","ETag":"match"}
-response source: Disk cache after validation
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=100, no-cache, must-revalidate","ETag":"match"}
-response source: Disk cache after validation
+response source: Disk cache
 
 response headers: {"ETag":"nomatch","Cache-control":"must-revalidate"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=0, must-revalidate","ETag":"nomatch"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=100, must-revalidate","ETag":"nomatch"}
 response source: Disk cache
@@ -159,13 +159,13 @@
 response source: Network
 
 response headers: {"Cache-control":"no-cache, must-revalidate","ETag":"nomatch"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=0, no-cache, must-revalidate","ETag":"nomatch"}
-response source: Network
+response source: Disk cache
 
 response headers: {"Cache-control":"max-age=100, no-cache, must-revalidate","ETag":"nomatch"}
-response source: Network
+response source: Disk cache
 
 PASS successfullyParsed is true
 

Modified: trunk/Source/WebKit2/ChangeLog (181733 => 181734)


--- trunk/Source/WebKit2/ChangeLog	2015-03-19 06:30:11 UTC (rev 181733)
+++ trunk/Source/WebKit2/ChangeLog	2015-03-19 07:54:06 UTC (rev 181734)
@@ -1,3 +1,41 @@
+2015-03-19  Chris Dumez  <[email protected]>
+
+        The network cache should ignore "cache-control: no-cache, must-revalidate" on history navigation
+        https://bugs.webkit.org/show_bug.cgi?id=142831
+        <rdar://problem/20209957>
+
+        Reviewed by Antti Koivisto.
+
+        The network cache should ignore "no-cache" and "must-revalidate" as
+        Cache-Control policy for history navigations to avoid unnecessary
+        revalidation in this case. Our memory cache already behaves this way.
+
+        On history navigation, our disk cache implementation currently
+        revalidates unconditionally resources if "cache-control: no-cache" is
+        used. It also revalidates expired resources if "cache-control:
+        must-revalidate" is used. This is sub-optimal.
+
+        RFC 7234 does not require us to do so [1]:
+        """
+          User agents often have history mechanisms, such as "Back" buttons and
+          history lists, that can be used to redisplay a representation
+          retrieved earlier in a session.
+
+          The freshness model (Section 4.2) does not necessarily apply to
+          history mechanisms.  That is, a history mechanism can display a
+          previous representation even if it has expired.
+        """
+
+        Chrome and IE9+ [2] already ignore "cache-control: must-revalidate" on history navigation.
+
+        [1] https://tools.ietf.org/html/rfc7234#page-32
+        [2] http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx
+
+        Test: http/tests/cache/disk-cache-validation-back-navigation-policy.html
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::decodeStorageEntry):
+
 2015-03-18  Simon Fraser  <[email protected]>
 
         Don't paint PDFs on every scroll

Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp (181733 => 181734)


--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp	2015-03-19 06:30:11 UTC (rev 181733)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp	2015-03-19 07:54:06 UTC (rev 181734)
@@ -206,12 +206,13 @@
         return nullptr;
     }
 
-    bool allowExpired = cachePolicyAllowsExpired(request.cachePolicy()) && !cachedResponse.cacheControlContainsMustRevalidate();
+    bool allowExpired = cachePolicyAllowsExpired(request.cachePolicy());
     auto timeStamp = std::chrono::duration_cast<std::chrono::duration<double>>(storageEntry.timeStamp);
     double age = WebCore::computeCurrentAge(cachedResponse, timeStamp.count());
     double lifetime = WebCore::computeFreshnessLifetimeForHTTPFamily(cachedResponse, timeStamp.count());
     bool isExpired = age > lifetime;
-    bool needsRevalidation = (isExpired && !allowExpired) || cachedResponse.cacheControlContainsNoCache();
+    // We never revalidate in the case of a history navigation (i.e. allowExpired is true).
+    bool needsRevalidation = !allowExpired && (cachedResponse.cacheControlContainsNoCache() || isExpired);
 
     if (needsRevalidation) {
         bool hasValidatorFields = cachedResponse.hasCacheValidatorFields();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to