- Revision
- 190942
- Author
- [email protected]
- Date
- 2015-10-13 03:00:43 -0700 (Tue, 13 Oct 2015)
Log Message
Merge r190320 - Memory cache revalidations should refresh the network disk cache
https://bugs.webkit.org/show_bug.cgi?id=149606
Reviewed by Darin Adler.
Source/WebKit2:
Previously, resource revalidations triggered by the memory cache would
bypass the disk cache entirely because the requests are conditional. As
a result, when the server responds with a 304, we were unable to update
the headers (e.g. new expiration date) of the corresponding entry in
the disk cache.
This patch updates our disk cache implementation to not bypass the disk
cache when the request is conditional. Instead, we look up the cached
entry and force its revalidation from the network. If the server then
returns a 304, we are now able to update the headers of this cached
entry. In such case though, we let the 304 response through to WebCore
unlike revalidations triggered by the disk cache.
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didReceiveResponseAsync):
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::makeUseDecision):
(WebKit::NetworkCache::makeRetrieveDecision):
LayoutTests:
Add layout test to check that revalidations requested by the memory cache
update the corresponding disk cache entry when the server responds with a
304 status code.
* http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache-expected.txt: Added.
* http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache.html: Added.
Modified Paths
Added Paths
Diff
Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog (190941 => 190942)
--- releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog 2015-10-13 09:48:06 UTC (rev 190941)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog 2015-10-13 10:00:43 UTC (rev 190942)
@@ -1,3 +1,17 @@
+2015-09-29 Chris Dumez <[email protected]>
+
+ Memory cache revalidations should refresh the network disk cache
+ https://bugs.webkit.org/show_bug.cgi?id=149606
+
+ Reviewed by Darin Adler.
+
+ Add layout test to check that revalidations requested by the memory cache
+ update the corresponding disk cache entry when the server responds with a
+ 304 status code.
+
+ * http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache-expected.txt: Added.
+ * http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache.html: Added.
+
2015-09-25 Carlos Garcia Campos <[email protected]>
[GTK] ASSERTION FAILED: !m_inUpdateBackingStoreState in DrawingAreaImpl::display() after DrawingAreaImpl::forceRepaint()
Added: releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache-expected.txt (0 => 190942)
--- releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache-expected.txt (rev 0)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache-expected.txt 2015-10-13 10:00:43 UTC (rev 190942)
@@ -0,0 +1,18 @@
+Tests that revalidations from the memory cache update the disk cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+running 1 tests
+
+Warming up cache...
+Load trough the Memory Cache...
+Clear the memory cache and load again, it should load from the disk cache *without* revalidation.
+response headers: {"Expires":"now(0)","ETag":"match"}
+response's 'Expires' header is overriden by future date in 304 response
+response source: Disk cache
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache.html (0 => 190942)
--- releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache.html (rev 0)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache.html 2015-10-13 10:00:43 UTC (rev 190942)
@@ -0,0 +1,34 @@
+<script src=""
+<script src=""
+<body>
+<script>
+
+var tests =
+[
+ { responseHeaders: {'Expires': 'now(0)', 'ETag': 'match' }, expiresInFutureIn304: true },
+];
+
+description("Tests that revalidations from the memory cache update the disk cache.");
+
+debug("running " + tests.length + " tests");
+debug("");
+
+function runTests(tests)
+{
+ debug("Warming up cache...");
+ loadResources(tests, function () {
+ debug("Load trough the Memory Cache...");
+ loadResourcesWithOptions(tests, { "SubresourceValidationPolicy": true }, function () {
+ debug("Clear the memory cache and load again, it should load from the disk cache *without* revalidation.");
+ loadResourcesWithOptions(tests, { "ClearMemoryCache" : true }, function () {
+ printResults(tests);
+ finishJSTest();
+ });
+ });
+ });
+}
+
+runTests(tests);
+
+</script>
+<script src=""
Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/platform/mac/TestExpectations (190941 => 190942)
--- releases/WebKitGTK/webkit-2.10/LayoutTests/platform/mac/TestExpectations 2015-10-13 09:48:06 UTC (rev 190941)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/platform/mac/TestExpectations 2015-10-13 10:00:43 UTC (rev 190942)
@@ -1100,10 +1100,6 @@
# Seems like this should happen everywhere, but it only does on Yosemite.
[ Yosemite+ ] http/tests/navigation/post-frames-goback1.html [ Pass Failure ]
-# FIXME: Needs bugzilla (<rdar://problem/16664245>)
-# We should land updated results if we can't get this bug fixed in time.
-[ Yosemite+ ] http/tests/xmlhttprequest/cache-override.html [ Failure ]
-
# FIXME: Needs bugzilla (<rdar://problem/16802068>)
[ Yosemite+ ] fast/css/input-search-padding.html [ Failure ]
Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog (190941 => 190942)
--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog 2015-10-13 09:48:06 UTC (rev 190941)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog 2015-10-13 10:00:43 UTC (rev 190942)
@@ -1,3 +1,29 @@
+2015-09-29 Chris Dumez <[email protected]>
+
+ Memory cache revalidations should refresh the network disk cache
+ https://bugs.webkit.org/show_bug.cgi?id=149606
+
+ Reviewed by Darin Adler.
+
+ Previously, resource revalidations triggered by the memory cache would
+ bypass the disk cache entirely because the requests are conditional. As
+ a result, when the server responds with a 304, we were unable to update
+ the headers (e.g. new expiration date) of the corresponding entry in
+ the disk cache.
+
+ This patch updates our disk cache implementation to not bypass the disk
+ cache when the request is conditional. Instead, we look up the cached
+ entry and force its revalidation from the network. If the server then
+ returns a 304, we are now able to update the headers of this cached
+ entry. In such case though, we let the 304 response through to WebCore
+ unlike revalidations triggered by the disk cache.
+
+ * NetworkProcess/NetworkResourceLoader.cpp:
+ (WebKit::NetworkResourceLoader::didReceiveResponseAsync):
+ * NetworkProcess/cache/NetworkCache.cpp:
+ (WebKit::NetworkCache::makeUseDecision):
+ (WebKit::NetworkCache::makeRetrieveDecision):
+
2015-09-25 Carlos Garcia Campos <[email protected]>
[GTK] ASSERTION FAILED: !m_inUpdateBackingStoreState in DrawingAreaImpl::display() after DrawingAreaImpl::forceRepaint()
Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp (190941 => 190942)
--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp 2015-10-13 09:48:06 UTC (rev 190941)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp 2015-10-13 10:00:43 UTC (rev 190942)
@@ -258,9 +258,13 @@
if (m_cacheEntryForValidation) {
bool validationSucceeded = m_response.httpStatusCode() == 304; // 304 Not Modified
- if (validationSucceeded)
+ if (validationSucceeded) {
NetworkCache::singleton().update(originalRequest(), m_parameters.webPageID, *m_cacheEntryForValidation, m_response);
- else
+ // If the request was conditional then this revalidation was not triggered by the network cache and we pass the
+ // 304 response to WebCore.
+ if (originalRequest().isConditional())
+ m_cacheEntryForValidation = nullptr;
+ } else
m_cacheEntryForValidation = nullptr;
}
shouldSendDidReceiveResponse = !m_cacheEntryForValidation;
@@ -590,12 +594,16 @@
{
ASSERT(!m_handle);
- String eTag = entry->response().httpHeaderField(WebCore::HTTPHeaderName::ETag);
- String lastModified = entry->response().httpHeaderField(WebCore::HTTPHeaderName::LastModified);
- if (!eTag.isEmpty())
- m_currentRequest.setHTTPHeaderField(WebCore::HTTPHeaderName::IfNoneMatch, eTag);
- if (!lastModified.isEmpty())
- m_currentRequest.setHTTPHeaderField(WebCore::HTTPHeaderName::IfModifiedSince, lastModified);
+ // If the request is already conditional then the revalidation was not triggered by the disk cache
+ // and we should not overwrite the existing conditional headers.
+ if (!m_currentRequest.isConditional()) {
+ String eTag = entry->response().httpHeaderField(WebCore::HTTPHeaderName::ETag);
+ String lastModified = entry->response().httpHeaderField(WebCore::HTTPHeaderName::LastModified);
+ if (!eTag.isEmpty())
+ m_currentRequest.setHTTPHeaderField(WebCore::HTTPHeaderName::IfNoneMatch, eTag);
+ if (!lastModified.isEmpty())
+ m_currentRequest.setHTTPHeaderField(WebCore::HTTPHeaderName::IfModifiedSince, lastModified);
+ }
m_cacheEntryForValidation = WTF::move(entry);
Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp (190941 => 190942)
--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp 2015-10-13 09:48:06 UTC (rev 190941)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp 2015-10-13 10:00:43 UTC (rev 190942)
@@ -204,6 +204,11 @@
static UseDecision makeUseDecision(const Entry& entry, const WebCore::ResourceRequest& request)
{
+ // The request is conditional so we force revalidation from the network. We merely check the disk cache
+ // so we can update the cache entry.
+ if (request.isConditional())
+ return UseDecision::Validate;
+
if (!verifyVaryingRequestHeaders(entry.varyingRequestHeaders(), request))
return UseDecision::NoDueToVaryingHeaderMismatch;
@@ -225,10 +230,7 @@
// FIXME: Support HEAD requests.
if (request.httpMethod() != "GET")
return RetrieveDecision::NoDueToHTTPMethod;
- // FIXME: We should be able to validate conditional requests using cache.
- if (request.isConditional())
- return RetrieveDecision::NoDueToConditionalRequest;
- if (request.cachePolicy() == WebCore::ReloadIgnoringCacheData)
+ if (request.cachePolicy() == WebCore::ReloadIgnoringCacheData && !request.isConditional())
return RetrieveDecision::NoDueToReloadIgnoringCache;
return RetrieveDecision::Yes;