Commit 37288fed authored by simonjam@chromium.org's avatar simonjam@chromium.org

Revalidate expired resources if they're requested after the initial document load

https://bugs.webkit.org/show_bug.cgi?id=52153

Reviewed by Antti Koivisto.

Source/WebCore:

Test: http/tests/cache/subresource-multiple-instances.html

* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::determineRevalidationPolicy):

LayoutTests:

* http/tests/cache/subresource-multiple-instances-expected.txt: Added.
* http/tests/cache/subresource-multiple-instances.html: Added.


git-svn-id: svn://svn.chromium.org/blink/trunk@93326 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6784f325
2011-08-18 James Simonsen <simonjam@chromium.org>
Revalidate expired resources if they're requested after the initial document load
https://bugs.webkit.org/show_bug.cgi?id=52153
Reviewed by Antti Koivisto.
* http/tests/cache/subresource-multiple-instances-expected.txt: Added.
* http/tests/cache/subresource-multiple-instances.html: Added.
2011-08-18 Tony Chang <tony@chromium.org> 2011-08-18 Tony Chang <tony@chromium.org>
[chromium] Marking tests needing win/linux baselines as such in [chromium] Marking tests needing win/linux baselines as such in
Verifies that resources are loaded only once during the initial document load, but are reloaded if they are requested again later and can not be cached.
PASS firstRandomNumber is non-zero.
PASS secondRandomNumber is non-zero.
PASS thirdRandomNumber is non-zero.
PASS firstRandomNumber == secondRandomNumber is true
PASS firstRandomNumber != thirdRandomNumber is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<title>Test Caching "no-store" For History Only</title>
<script src="../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<p>Verifies that resources are loaded only once during the initial document
load, but are reloaded if they are requested again later and can not be cached.
</p>
<pre id="console"></pre>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
}
var randomNumber = 0;
var firstRandomNumber = 0;
var secondRandomNumber = 0;
var thirdRandomNumber = 0;
function firstLoaded() {
firstRandomNumber = randomNumber;
var newScript = document.createElement("script");
newScript.src = "resources/cache-simulator.cgi?uniqueId=1&Cache-control=max-age=0";
newScript.onload = secondLoaded;
document.getElementsByTagName("head")[0].appendChild(newScript);
}
function secondLoaded() {
secondRandomNumber = randomNumber;
}
function loadNextScript() {
var newScript = document.createElement("script");
newScript.src = "resources/cache-simulator.cgi?uniqueId=1&Cache-control=max-age=0";
newScript.onload = thirdLoaded;
document.getElementsByTagName("head")[0].appendChild(newScript);
}
function thirdLoaded() {
thirdRandomNumber = randomNumber;
shouldBeNonZero("firstRandomNumber");
shouldBeNonZero("secondRandomNumber");
shouldBeNonZero("thirdRandomNumber");
shouldBeTrue("firstRandomNumber == secondRandomNumber");
shouldBeTrue("firstRandomNumber != thirdRandomNumber");
finishJSTest();
}
window.addEventListener("load", function() { setTimeout(loadNextScript, 0); }, false);
var jsTestIsAsync = true;
var successfullyParsed = true;
</script>
<script src="resources/cache-simulator.cgi?uniqueId=1&Cache-control=max-age=0" onload="firstLoaded()" async></script>
<script src="../../js-test-resources/js-test-post.js"></script>
</body>
</html>
2011-08-18 James Simonsen <simonjam@chromium.org>
Revalidate expired resources if they're requested after the initial document load
https://bugs.webkit.org/show_bug.cgi?id=52153
Reviewed by Antti Koivisto.
Test: http/tests/cache/subresource-multiple-instances.html
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::determineRevalidationPolicy):
2011-08-18 Anders Carlsson <andersca@apple.com> 2011-08-18 Anders Carlsson <andersca@apple.com>
Fix clang libc++ C++0x build Fix clang libc++ C++0x build
...@@ -474,10 +474,10 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida ...@@ -474,10 +474,10 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida
return Reload; return Reload;
} }
// Avoid loading the same resource multiple times for a single document, even if the cache policies would tell us to. // During the initial load, avoid loading the same resource multiple times for a single document, even if the cache policies would tell us to.
if (m_validatedURLs.contains(existingResource->url())) if (!document()->loadEventFinished() && m_validatedURLs.contains(existingResource->url()))
return Use; return Use;
// CachePolicyReload always reloads // CachePolicyReload always reloads
if (cachePolicy() == CachePolicyReload) { if (cachePolicy() == CachePolicyReload) {
LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to CachePolicyReload."); LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to CachePolicyReload.");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment