[WK2] The WebKit network cache does not cache responses with "Content-Disposition...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Mar 2015 16:44:19 +0000 (16:44 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Mar 2015 16:44:19 +0000 (16:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142989
<rdar://problem/20265992>

Reviewed by Antti Koivisto.

Source/WebKit2:

Update our WebKit network cache policy to cache responses with
"Content-Disposition: attachment" header. There is no reason we cannot
cache these and our memory cache already does.

This was causing a decent amount of cache misses in the wild. I have
noticed for example that when loading disney.com, we fail to cache the
following resources because of this policy:
http://pagead2.googlesyndication.com/pagead/osd.js
http://pagead2.googlesyndication.com/pagead/show_companion_ad.js

Those resources have Cache-Control headers that indicate they are meant
to be cacheable.

Test: http/tests/cache/disk-cache-validation-attachment.html

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

LayoutTests:

Add layout test to check that resources whose response has the
"Content-Disposition: attachment" header are cacheable.

Also move all disk cache layout tests to a disk-cache sub-folder to
facilitate skipping on platforms that don't have the WebKit network
disk cache.

* http/tests/cache/disk-cache/disk-cache-disable-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-disable-expected.txt.
* http/tests/cache/disk-cache/disk-cache-disable.html: Renamed from LayoutTests/http/tests/cache/disk-cache-disable.html.
* http/tests/cache/disk-cache/disk-cache-redirect-to-data-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-redirect-to-data-expected.txt.
* http/tests/cache/disk-cache/disk-cache-redirect-to-data.html: Renamed from LayoutTests/http/tests/cache/disk-cache-redirect-to-data.html.
* http/tests/cache/disk-cache/disk-cache-validation-attachment-expected.txt: Added.
* http/tests/cache/disk-cache/disk-cache-validation-attachment.html: Added.
* http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt.
* http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy.html: Renamed from LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy.html.
* http/tests/cache/disk-cache/disk-cache-validation-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-validation-expected.txt.
* http/tests/cache/disk-cache/disk-cache-validation.html: Renamed from LayoutTests/http/tests/cache/disk-cache-validation.html.
* http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-vary-cookie-expected.txt.
* http/tests/cache/disk-cache/disk-cache-vary-cookie.html: Renamed from LayoutTests/http/tests/cache/disk-cache-vary-cookie.html.
* http/tests/cache/disk-cache/resources/cache-test.js: Renamed from LayoutTests/http/tests/cache/resources/cache-test.js.
* http/tests/cache/disk-cache/resources/generate-response.cgi: Renamed from LayoutTests/http/tests/cache/resources/generate-response.cgi.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181894 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache/disk-cache/disk-cache-disable-expected.txt [moved from LayoutTests/http/tests/cache/disk-cache-disable-expected.txt with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/disk-cache-disable.html [moved from LayoutTests/http/tests/cache/disk-cache-disable.html with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/disk-cache-redirect-to-data-expected.txt [moved from LayoutTests/http/tests/cache/disk-cache-redirect-to-data-expected.txt with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/disk-cache-redirect-to-data.html [moved from LayoutTests/http/tests/cache/disk-cache-redirect-to-data.html with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-attachment-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-attachment.html [new file with mode: 0644]
LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy-expected.txt [moved from LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy.html [moved from LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy.html with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-expected.txt [moved from LayoutTests/http/tests/cache/disk-cache-validation-expected.txt with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/disk-cache-validation.html [moved from LayoutTests/http/tests/cache/disk-cache-validation.html with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt [moved from LayoutTests/http/tests/cache/disk-cache-vary-cookie-expected.txt with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html [moved from LayoutTests/http/tests/cache/disk-cache-vary-cookie.html with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js [moved from LayoutTests/http/tests/cache/resources/cache-test.js with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/resources/generate-response.cgi [moved from LayoutTests/http/tests/cache/resources/generate-response.cgi with 100% similarity]
LayoutTests/http/tests/cache/disk-cache/resources/redirect-to-data.php [moved from LayoutTests/http/tests/cache/resources/redirect-to-data.php with 100% similarity]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

index 99a3a07..c4d03fe 100644 (file)
@@ -1,3 +1,37 @@
+2015-03-24  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] The WebKit network cache does not cache responses with "Content-Disposition: attachment" header
+        https://bugs.webkit.org/show_bug.cgi?id=142989
+        <rdar://problem/20265992>
+
+        Reviewed by Antti Koivisto.
+
+        Add layout test to check that resources whose response has the
+        "Content-Disposition: attachment" header are cacheable.
+
+        Also move all disk cache layout tests to a disk-cache sub-folder to
+        facilitate skipping on platforms that don't have the WebKit network
+        disk cache.
+
+        * http/tests/cache/disk-cache/disk-cache-disable-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-disable-expected.txt.
+        * http/tests/cache/disk-cache/disk-cache-disable.html: Renamed from LayoutTests/http/tests/cache/disk-cache-disable.html.
+        * http/tests/cache/disk-cache/disk-cache-redirect-to-data-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-redirect-to-data-expected.txt.
+        * http/tests/cache/disk-cache/disk-cache-redirect-to-data.html: Renamed from LayoutTests/http/tests/cache/disk-cache-redirect-to-data.html.
+        * http/tests/cache/disk-cache/disk-cache-validation-attachment-expected.txt: Added.
+        * http/tests/cache/disk-cache/disk-cache-validation-attachment.html: Added.
+        * http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt.
+        * http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy.html: Renamed from LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy.html.
+        * http/tests/cache/disk-cache/disk-cache-validation-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-validation-expected.txt.
+        * http/tests/cache/disk-cache/disk-cache-validation.html: Renamed from LayoutTests/http/tests/cache/disk-cache-validation.html.
+        * http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt: Renamed from LayoutTests/http/tests/cache/disk-cache-vary-cookie-expected.txt.
+        * http/tests/cache/disk-cache/disk-cache-vary-cookie.html: Renamed from LayoutTests/http/tests/cache/disk-cache-vary-cookie.html.
+        * http/tests/cache/disk-cache/resources/cache-test.js: Renamed from LayoutTests/http/tests/cache/resources/cache-test.js.
+        * http/tests/cache/disk-cache/resources/generate-response.cgi: Renamed from LayoutTests/http/tests/cache/resources/generate-response.cgi.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/win/TestExpectations:
+
 2015-03-24  Michael Saboff  <msaboff@apple.com>
 
         REGRESSION (172175-172177): Change in for...in processing causes properties added in loop to be enumerated
diff --git a/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-attachment-expected.txt b/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-attachment-expected.txt
new file mode 100644 (file)
index 0000000..58384f4
--- /dev/null
@@ -0,0 +1,29 @@
+Tests that responses with 'content-disposition: attachment' are cacheable
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+running 6 tests
+
+response headers: undefined
+response source: Network
+
+response headers: {"Cache-control":"max-age=0"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100"}
+response source: Disk cache
+
+response headers: {"Content-Disposition":"attachment; filename=\"f.txt\""}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0","Content-Disposition":"attachment; filename=\"f.txt\""}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100","Content-Disposition":"attachment; filename=\"f.txt\""}
+response source: Disk cache
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-attachment.html b/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-attachment.html
new file mode 100644 (file)
index 0000000..e62d7af
--- /dev/null
@@ -0,0 +1,29 @@
+<script src="/js-test-resources/js-test-pre.js"></script>
+<script src="resources/cache-test.js"></script>
+<body>
+<script>
+
+var testMatrix =
+[
+ [
+  {},
+  { responseHeaders: {'Cache-control': 'max-age=0' } },
+  { responseHeaders: {'Cache-control': 'max-age=100' } },
+  ],
+ [
+  {},
+  { responseHeaders: {'Content-Disposition': 'attachment; filename="f.txt"' } },
+  ],
+ ];
+
+description("Tests that responses with 'content-disposition: attachment' are cacheable");
+
+var tests = generateTests(testMatrix);
+
+debug("running " + tests.length + " tests");
+debug("");
+
+runTests(tests);
+
+</script>
+<script src="/js-test-resources/js-test-post.js"></script>
index 8173744..02533b6 100644 (file)
@@ -2123,9 +2123,7 @@ webkit.org/b/141628 compositing/layer-creation/fixed-position-out-of-view-scaled
 webkit.org/b/141628 compositing/layer-creation/fixed-position-out-of-view-scaled.html [ Failure ]
 
 # Disk cache isn't supported by EFL port yet.
-webkit.org/b/141891 http/tests/cache/disk-cache-disable.html [ Failure ]
-webkit.org/b/141891 http/tests/cache/disk-cache-redirect-to-data.html [ Failure ]
-webkit.org/b/141891 http/tests/cache/disk-cache-validation.html [ Failure ]
+webkit.org/b/141891 http/tests/cache/disk-cache [ Skip ]
 
 webkit.org/b/141892 fast/sub-pixel/client-width-height-snapping.html [ Failure ]
 webkit.org/b/141892 fast/sub-pixel/inline-block-with-padding.html [ Failure ]
index 6641319..e713276 100644 (file)
@@ -496,6 +496,9 @@ webkit.org/b/128172 fast/events/touch/touch-target.html [ Timeout ]
 webkit.org/b/128172 fast/events/touch/touch-target-limited.html [ Crash Timeout ]
 webkit.org/b/128172 fast/events/touch/send-oncancel-event.html [ Timeout ]
 
+# The WebKit network disk cache is not enabled on the GTK port.
+webkit.org/b/142821 http/tests/cache/disk-cache [ Skip ]
+
 # HighDPI support is not enabled
 webkit.org/b/131347 fast/backgrounds/hidpi-background-image-contain-cover-scale-needs-more-precision.html [ ImageOnlyFailure ]
 webkit.org/b/131347 fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position.html [ ImageOnlyFailure ]
@@ -571,8 +574,6 @@ webkit.org/b/141699 fast/attachment/attachment-rendering.html [ Failure ]
 webkit.org/b/141700 fast/dom/Element/getClientRects.html [ Failure ]
 webkit.org/b/141700 fast/dom/Range/getClientRects.html [ Failure ]
 
-webkit.org/b/141702 http/tests/cache/disk-cache-disable.html [ Failure ]
-webkit.org/b/141703 http/tests/cache/disk-cache-redirect-to-data.html [ Failure ]
 webkit.org/b/141705 media/video-fullscreeen-only-controls.html [ Failure ]
 webkit.org/b/141706 fast/forms/color/input-appearance-color.html [ Failure ]
 webkit.org/b/141709 http/tests/security/XFrameOptions/x-frame-options-deny-multiple-clients.html [ Failure ]
@@ -621,7 +622,6 @@ webkit.org/b/142289 mathml/presentation/scripts-subsup.html [ ImageOnlyFailure ]
 
 webkit.org/b/141074 accessibility/auto-filled-value.html [ Missing ]
 
-webkit.org/b/142818 http/tests/cache/disk-cache-vary-cookie.html [ Failure ]
 webkit.org/b/142819 fast/text/baseline-inline-block.html [ ImageOnlyFailure ]
 
 webkit.org/b/142823 fast/attachment/attachment-progress.html [ Missing ]
@@ -1321,7 +1321,6 @@ webkit.org/b/142491 media/media-source/media-source-stalled-holds-sleep-assertio
 
 webkit.org/b/142670 media/video-background-tab-playback.html [ Timeout ]
 webkit.org/b/142820 fast/images/animated-gif-body-outside-viewport.html [ Timeout ]
-webkit.org/b/142821 http/tests/cache/disk-cache-validation.html [ Timeout ]
 
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of Tests timing out
index 713764d..a23eccf 100644 (file)
@@ -92,10 +92,7 @@ compositing/rtl/rtl-fixed-overflow-scrolled.html [ Failure ]
 compositing/iframes/overlapped-nested-iframes.html [ Pass Failure ]
 
 # Disk cache is WK2 only
-http/tests/cache/disk-cache-validation.html
-http/tests/cache/disk-cache-validation-back-navigation-policy.html
-http/tests/cache/disk-cache-disable.html
-http/tests/cache/disk-cache-vary-cookie.html
+http/tests/cache/disk-cache
 
 ### END OF (2) Failures without bug reports
 ########################################
index b16d39d..622bed7 100644 (file)
@@ -2226,10 +2226,7 @@ webkit.org/b/29213 http/tests/security/mixedContent [ Skip ]
 webkit.org/b/60206 http/tests/navigation/response204.html [ Failure ]
 
 # Disk cache is WK2 only
-http/tests/cache/disk-cache-validation.html
-http/tests/cache/disk-cache-validation-back-navigation-policy.html
-http/tests/cache/disk-cache-disable.html
-http/tests/cache/disk-cache-vary-cookie.html
+http/tests/cache/disk-cache
 
 # The following are unreviewed:
 http/tests/cache/content-type-ignored-during-revalidation.html [ Failure ]
index 5e6847c..56ba3d9 100644 (file)
@@ -1,3 +1,29 @@
+2015-03-24  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] The WebKit network cache does not cache responses with "Content-Disposition: attachment" header
+        https://bugs.webkit.org/show_bug.cgi?id=142989
+        <rdar://problem/20265992>
+
+        Reviewed by Antti Koivisto.
+
+        Update our WebKit network cache policy to cache responses with
+        "Content-Disposition: attachment" header. There is no reason we cannot
+        cache these and our memory cache already does.
+
+        This was causing a decent amount of cache misses in the wild. I have
+        noticed for example that when loading disney.com, we fail to cache the
+        following resources because of this policy:
+        http://pagead2.googlesyndication.com/pagead/osd.js
+        http://pagead2.googlesyndication.com/pagead/show_companion_ad.js
+
+        Those resources have Cache-Control headers that indicate they are meant
+        to be cacheable.
+
+        Test: http/tests/cache/disk-cache-validation-attachment.html
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::canStore):
+
 2015-03-23  Joseph Pecoraro  <pecoraro@apple.com>
 
         Unreviewed, another attempt to fix 32-bit build after r181881.
index 925ddb0..4b5e959 100644 (file)
@@ -317,10 +317,6 @@ static StoreDecision canStore(const WebCore::ResourceRequest& originalRequest, c
         LOG(NetworkCache, "(NetworkProcess) method %s", originalRequest.httpMethod().utf8().data());
         return StoreDecision::NoDueToHTTPMethod;
     }
-    if (response.isAttachment()) {
-        LOG(NetworkCache, "(NetworkProcess) attachment");
-        return StoreDecision::NoDueToAttachmentResponse;
-    }
 
     switch (response.httpStatusCode()) {
     case 200: // OK