<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[182152] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/182152">182152</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2015-03-30 14:09:14 -0700 (Mon, 30 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Don't cache resources that are very unlikely to be reused
https://bugs.webkit.org/show_bug.cgi?id=143226
&lt;rdar://problem/20347160&gt;

Reviewed by Geoff Garen.

Source/WebCore:

Allow overriding resource load priorities via Internals for testing.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::addExtraFieldsToRequest):
(WebCore::FrameLoader::clearTestingOverrides):
* loader/FrameLoader.h:
(WebCore::FrameLoader::setOverrideResourceLoadPriorityForTesting):
(WebCore::FrameLoader::clearOverrideCachePolicyForTesting): Deleted.
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::unlikelyToReuseKey):
* page/DiagnosticLoggingKeys.h:

    Add a key.

* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::stringToResourceLoadPriority):
(WebCore::Internals::setOverrideResourceLoadPriority):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2:

We are writing lots of resources to the cache that are never used again.

In browse-around-randomly test this reduced number of cache entries created by ~20% and bytes written by ~5%.

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::makeUseDecision):
(WebKit::NetworkCache::makeRetrieveDecision):

    Rename for clarity.

(WebKit::NetworkCache::makeStoreDecision):

    Store only if the resource has non-zero expiration or has validation headers.

    Very High priority resources (main resources) keep the existing policy to minimize impact
    on back navigation and tab restore.

(WebKit::NetworkCache::Cache::retrieve):
(WebKit::NetworkCache::Cache::store):
(WebKit::NetworkCache::canUse): Deleted.
(WebKit::NetworkCache::canRetrieve): Deleted.
(WebKit::NetworkCache::canStore): Deleted.
* NetworkProcess/cache/NetworkCache.h:
* NetworkProcess/cache/NetworkCacheStatistics.cpp:
(WebKit::NetworkCache::storeDecisionToDiagnosticKey):

LayoutTests:

* http/tests/cache/disk-cache/disk-cache-request-max-stale-expected.txt:
* http/tests/cache/disk-cache/disk-cache-request-max-stale-expected.html:

    Keep max-age: 0 cacheable in this test by adding a validation header.

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

    Rebase and expand to cover the high priority resource case.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcacherequestmaxstaleexpectedtxt">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-request-max-stale-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcacherequestmaxstalehtml">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-request-max-stale.html</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcachevalidationbacknavigationpolicyexpectedtxt">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcachevalidationbacknavigationpolicyhtml">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoaderh">trunk/Source/WebCore/loader/FrameLoader.h</a></li>
<li><a href="#trunkSourceWebCorepageDiagnosticLoggingKeyscpp">trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDiagnosticLoggingKeysh">trunk/Source/WebCore/page/DiagnosticLoggingKeys.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheh">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheStatisticscpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/LayoutTests/ChangeLog        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2015-03-30  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Don't cache resources that are very unlikely to be reused
+        https://bugs.webkit.org/show_bug.cgi?id=143226
+        &lt;rdar://problem/20347160&gt;
+
+        Reviewed by Geoff Garen.
+
+        * http/tests/cache/disk-cache/disk-cache-request-max-stale-expected.txt:
+        * http/tests/cache/disk-cache/disk-cache-request-max-stale-expected.html:
+
+            Keep max-age: 0 cacheable in this test by adding a validation header.
+
+        * http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy-expected.txt:
+        * http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy.html:
+
+            Rebase and expand to cover the high priority resource case.
+
</ins><span class="cx"> 2015-03-30  Marcos Chavarría Teijeiro  &lt;chavarria1991@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rebaseline accessibility/aria-toggle-button-with-title.html
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcacherequestmaxstaleexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-request-max-stale-expected.txt (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-request-max-stale-expected.txt        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-request-max-stale-expected.txt        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -5,23 +5,23 @@
</span><span class="cx"> 
</span><span class="cx"> running 36 tests
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Age&quot;:&quot;200&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;,&quot;Age&quot;:&quot;200&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Age&quot;:&quot;200&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0&quot;}
</span><span class="cx"> response source: Network
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Age&quot;:&quot;200&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;,&quot;Age&quot;:&quot;200&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><span class="lines">@@ -45,79 +45,79 @@
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Age&quot;:&quot;200&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;,&quot;Age&quot;:&quot;200&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Age&quot;:&quot;200&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100&quot;}
</span><span class="cx"> response source: Network
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0, max-age=0&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0, max-age=0&quot;}
</span><span class="cx"> response source: Network
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Age&quot;:&quot;200&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;,&quot;Age&quot;:&quot;200&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0, max-age=0&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Age&quot;:&quot;200&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0, max-age=0&quot;}
</span><span class="cx"> response source: Network
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale, max-age=0&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale, max-age=0&quot;}
</span><span class="cx"> response source: Network
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Age&quot;:&quot;200&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;,&quot;Age&quot;:&quot;200&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale, max-age=0&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Age&quot;:&quot;200&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale, max-age=0&quot;}
</span><span class="cx"> response source: Network
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100, max-age=0&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100, max-age=0&quot;}
</span><span class="cx"> response source: Network
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Age&quot;:&quot;200&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;,&quot;Age&quot;:&quot;200&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100, max-age=0&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Age&quot;:&quot;200&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100, max-age=0&quot;}
</span><span class="cx"> response source: Network
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0, max-age=100&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0, max-age=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Age&quot;:&quot;200&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;,&quot;Age&quot;:&quot;200&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0, max-age=100&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Age&quot;:&quot;200&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=0, max-age=100&quot;}
</span><span class="cx"> response source: Network
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale, max-age=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><span class="lines">@@ -125,7 +125,7 @@
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale, max-age=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Age&quot;:&quot;200&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;,&quot;Age&quot;:&quot;200&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale, max-age=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><span class="lines">@@ -133,7 +133,7 @@
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale, max-age=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100, max-age=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><span class="lines">@@ -141,9 +141,9 @@
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100, max-age=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><del>-response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Age&quot;:&quot;200&quot;}
</del><ins>+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;,&quot;Age&quot;:&quot;200&quot;}
</ins><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100, max-age=100&quot;}
</span><del>-response source: Network
</del><ins>+response source: Disk cache after validation
</ins><span class="cx"> 
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Age&quot;:&quot;200&quot;}
</span><span class="cx"> request headers: {&quot;Cache-control&quot;:&quot;max-stale=100, max-age=100&quot;}
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcacherequestmaxstalehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-request-max-stale.html (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-request-max-stale.html        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-request-max-stale.html        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -6,7 +6,7 @@
</span><span class="cx"> var testMatrix =
</span><span class="cx"> [
</span><span class="cx">  [
</span><del>-  { responseHeaders: {'Cache-control': 'max-age=0' } },
</del><ins>+  { responseHeaders: {'Cache-control': 'max-age=0', 'ETag': 'match' } },
</ins><span class="cx">   { responseHeaders: {'Cache-control': 'max-age=100' } },
</span><span class="cx">   ],
</span><span class="cx">  [
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcachevalidationbacknavigationpolicyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy-expected.txt (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy-expected.txt        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy-expected.txt        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -6,8 +6,172 @@
</span><span class="cx"> running 54 tests
</span><span class="cx"> 
</span><span class="cx"> response headers: undefined
</span><ins>+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</ins><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><ins>+response headers: {&quot;Cache-control&quot;:&quot;no-store&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-store&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-store&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;no-cache&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-cache&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-cache&quot;}
+response source: Disk cache
+
+response headers: {&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;no-store&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-store&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-store&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;no-cache&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-cache&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-cache&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;no-store&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-store&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-store&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;no-cache&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-cache&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-cache&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;must-revalidate&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, must-revalidate&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, must-revalidate&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;no-store, must-revalidate&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-store, must-revalidate&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-store, must-revalidate&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;no-cache, must-revalidate&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-cache, must-revalidate&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-cache, must-revalidate&quot;}
+response source: Disk cache
+
+response headers: {&quot;ETag&quot;:&quot;match&quot;,&quot;Cache-control&quot;:&quot;must-revalidate&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, must-revalidate&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, must-revalidate&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;no-store, must-revalidate&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-store, must-revalidate&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-store, must-revalidate&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;no-cache, must-revalidate&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-cache, must-revalidate&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-cache, must-revalidate&quot;,&quot;ETag&quot;:&quot;match&quot;}
+response source: Disk cache
+
+response headers: {&quot;ETag&quot;:&quot;nomatch&quot;,&quot;Cache-control&quot;:&quot;must-revalidate&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, must-revalidate&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, must-revalidate&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;no-store, must-revalidate&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-store, must-revalidate&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-store, must-revalidate&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;no-cache, must-revalidate&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0, no-cache, must-revalidate&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100, no-cache, must-revalidate&quot;,&quot;ETag&quot;:&quot;nomatch&quot;}
+response source: Disk cache
+
+Testing high priority resources
+
+response headers: undefined
+response source: Disk cache
+
</ins><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcachevalidationbacknavigationpolicyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy.html (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy.html        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-back-navigation-policy.html        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -36,7 +36,12 @@
</span><span class="cx"> debug(&quot;running &quot; + tests.length + &quot; tests&quot;);
</span><span class="cx"> debug(&quot;&quot;);
</span><span class="cx"> 
</span><del>-runTests(tests);
</del><ins>+runTests(tests, function () {
+    debug(&quot;Testing high priority resources&quot;);
+    debug(&quot;&quot;);
+    internals.setOverrideResourceLoadPriority(&quot;ResourceLoadPriorityVeryHigh&quot;);
+    runTests(tests);
+});
</ins><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;script src=&quot;/js-test-resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebCore/ChangeLog        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2015-03-30  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Don't cache resources that are very unlikely to be reused
+        https://bugs.webkit.org/show_bug.cgi?id=143226
+        &lt;rdar://problem/20347160&gt;
+
+        Reviewed by Geoff Garen.
+
+        Allow overriding resource load priorities via Internals for testing.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::addExtraFieldsToRequest):
+        (WebCore::FrameLoader::clearTestingOverrides):
+        * loader/FrameLoader.h:
+        (WebCore::FrameLoader::setOverrideResourceLoadPriorityForTesting):
+        (WebCore::FrameLoader::clearOverrideCachePolicyForTesting): Deleted.
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::unlikelyToReuseKey):
+        * page/DiagnosticLoggingKeys.h:
+
+            Add a key.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+        (WebCore::stringToResourceLoadPriority):
+        (WebCore::Internals::setOverrideResourceLoadPriority):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
</ins><span class="cx"> 2015-03-30  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Grid Layout] Upgrade align-self and align-items parsing to CSS 3
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -2561,6 +2561,8 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_overrideCachePolicyForTesting)
</span><span class="cx">         request.setCachePolicy(m_overrideCachePolicyForTesting.value());
</span><ins>+    if (m_overrideResourceLoadPriorityForTesting)
+        request.setPriority(m_overrideResourceLoadPriorityForTesting.value());
</ins><span class="cx"> 
</span><span class="cx">     if (request.cachePolicy() == ReloadIgnoringCacheData) {
</span><span class="cx">         if (loadType == FrameLoadType::Reload)
</span><span class="lines">@@ -3413,6 +3415,12 @@
</span><span class="cx">     m_client.forcePageTransitionIfNeeded();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FrameLoader::clearTestingOverrides()
+{
+    m_overrideCachePolicyForTesting = Nullopt;
+    m_overrideResourceLoadPriorityForTesting = Nullopt;
+}
+
</ins><span class="cx"> bool FrameLoaderClient::hasHTMLView() const
</span><span class="cx"> {
</span><span class="cx">     return true;
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.h (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.h        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebCore/loader/FrameLoader.h        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -290,7 +290,8 @@
</span><span class="cx">     void forcePageTransitionIfNeeded();
</span><span class="cx"> 
</span><span class="cx">     void setOverrideCachePolicyForTesting(ResourceRequestCachePolicy policy) { m_overrideCachePolicyForTesting = policy; }
</span><del>-    void clearOverrideCachePolicyForTesting() { m_overrideCachePolicyForTesting = Nullopt; }
</del><ins>+    void setOverrideResourceLoadPriorityForTesting(ResourceLoadPriority priority) { m_overrideResourceLoadPriorityForTesting = priority; }
+    WEBCORE_EXPORT void clearTestingOverrides();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     enum FormSubmissionCacheLoadPolicy {
</span><span class="lines">@@ -442,6 +443,7 @@
</span><span class="cx">     RefPtr&lt;FrameNetworkingContext&gt; m_networkingContext;
</span><span class="cx"> 
</span><span class="cx">     Optional&lt;ResourceRequestCachePolicy&gt; m_overrideCachePolicyForTesting;
</span><ins>+    Optional&lt;ResourceLoadPriority&gt; m_overrideResourceLoadPriorityForTesting;
</ins><span class="cx"> 
</span><span class="cx">     URL m_previousURL;
</span><span class="cx">     RefPtr&lt;HistoryItem&gt; m_requestedHistoryItem;
</span></span></pre></div>
<a id="trunkSourceWebCorepageDiagnosticLoggingKeyscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -383,6 +383,11 @@
</span><span class="cx">     return ASCIILiteral(&quot;uncacheableStatusCode&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String DiagnosticLoggingKeys::unlikelyToReuseKey()
+{
+    return ASCIILiteral(&quot;unlikelyToReuse&quot;);
+}
+
</ins><span class="cx"> String DiagnosticLoggingKeys::unsupportedHTTPMethodKey()
</span><span class="cx"> {
</span><span class="cx">     return ASCIILiteral(&quot;unsupportedHTTPMethod&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCorepageDiagnosticLoggingKeysh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -108,6 +108,7 @@
</span><span class="cx">     static String styleSheetKey();
</span><span class="cx">     static String svgDocumentKey();
</span><span class="cx">     WEBCORE_EXPORT static String uncacheableStatusCodeKey();
</span><ins>+    WEBCORE_EXPORT static String unlikelyToReuseKey();
</ins><span class="cx">     WEBCORE_EXPORT static String unsupportedHTTPMethodKey();
</span><span class="cx">     static String unsuspendableDOMObjectKey();
</span><span class="cx">     WEBCORE_EXPORT static String unusableCachedEntryKey();
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebCore/testing/Internals.cpp        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -308,7 +308,7 @@
</span><span class="cx">         page-&gt;mainFrame().editor().toggleContinuousSpellChecking();
</span><span class="cx">     if (page-&gt;mainFrame().editor().isOverwriteModeEnabled())
</span><span class="cx">         page-&gt;mainFrame().editor().toggleOverwriteModeEnabled();
</span><del>-    page-&gt;mainFrame().loader().clearOverrideCachePolicyForTesting();
</del><ins>+    page-&gt;mainFrame().loader().clearTestingOverrides();
</ins><span class="cx">     ApplicationCacheStorage::singleton().setDefaultOriginQuota(ApplicationCacheStorage::noQuota());
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx">     MediaSessionManager::sharedManager().resetRestrictions();
</span><span class="lines">@@ -445,6 +445,27 @@
</span><span class="cx">     frame()-&gt;loader().setOverrideCachePolicyForTesting(stringToResourceRequestCachePolicy(policy));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static ResourceLoadPriority stringToResourceLoadPriority(const String&amp; policy)
+{
+    if (policy == &quot;ResourceLoadPriorityVeryLow&quot;)
+        return ResourceLoadPriorityVeryLow;
+    if (policy == &quot;ResourceLoadPriorityLow&quot;)
+        return ResourceLoadPriorityLow;
+    if (policy == &quot;ResourceLoadPriorityMedium&quot;)
+        return ResourceLoadPriorityMedium;
+    if (policy == &quot;ResourceLoadPriorityHigh&quot;)
+        return ResourceLoadPriorityHigh;
+    if (policy == &quot;ResourceLoadPriorityVeryHigh&quot;)
+        return ResourceLoadPriorityVeryHigh;
+    ASSERT_NOT_REACHED();
+    return ResourceLoadPriorityLow;
+}
+
+void Internals::setOverrideResourceLoadPriority(const String&amp; priority)
+{
+    frame()-&gt;loader().setOverrideResourceLoadPriorityForTesting(stringToResourceLoadPriority(priority));
+}
+
</ins><span class="cx"> void Internals::clearMemoryCache()
</span><span class="cx"> {
</span><span class="cx">     MemoryCache::singleton().evictResources();
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebCore/testing/Internals.h        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -90,6 +90,7 @@
</span><span class="cx">     bool isLoadingFromMemoryCache(const String&amp; url);
</span><span class="cx">     String xhrResponseSource(XMLHttpRequest*);
</span><span class="cx">     void setOverrideCachePolicy(const String&amp;);
</span><ins>+    void setOverrideResourceLoadPriority(const String&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void clearMemoryCache();
</span><span class="cx">     void pruneMemoryCacheToSize(unsigned size);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebCore/testing/Internals.idl        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -37,6 +37,13 @@
</span><span class="cx">     &quot;ReturnCacheDataDontLoad&quot;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum ResourceLoadPriority {
+    &quot;ResourceLoadPriorityVeryLow&quot;,
+    &quot;ResourceLoadPriorityLow&quot;,
+    &quot;ResourceLoadPriorityMedium&quot;,
+    &quot;ResourceLoadPriorityHigh&quot;,
+    &quot;ResourceLoadPriorityVeryHigh&quot;
+};
</ins><span class="cx"> 
</span><span class="cx"> [
</span><span class="cx">     NoInterfaceObject,
</span><span class="lines">@@ -56,6 +63,7 @@
</span><span class="cx">     void pruneMemoryCacheToSize(long size);
</span><span class="cx">     long memoryCacheSize();
</span><span class="cx">     void setOverrideCachePolicy(CachePolicy policy);
</span><ins>+    void setOverrideResourceLoadPriority(ResourceLoadPriority priority);
</ins><span class="cx"> 
</span><span class="cx">     void clearPageCache();
</span><span class="cx">     unsigned int pageCacheSize();
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebKit2/ChangeLog        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2015-03-30  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Don't cache resources that are very unlikely to be reused
+        https://bugs.webkit.org/show_bug.cgi?id=143226
+        &lt;rdar://problem/20347160&gt;
+
+        Reviewed by Geoff Garen.
+
+        We are writing lots of resources to the cache that are never used again.
+
+        In browse-around-randomly test this reduced number of cache entries created by ~20% and bytes written by ~5%.
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::makeUseDecision):
+        (WebKit::NetworkCache::makeRetrieveDecision):
+
+            Rename for clarity.
+
+        (WebKit::NetworkCache::makeStoreDecision):
+
+            Store only if the resource has non-zero expiration or has validation headers.
+
+            Very High priority resources (main resources) keep the existing policy to minimize impact
+            on back navigation and tab restore.
+
+        (WebKit::NetworkCache::Cache::retrieve):
+        (WebKit::NetworkCache::Cache::store):
+        (WebKit::NetworkCache::canUse): Deleted.
+        (WebKit::NetworkCache::canRetrieve): Deleted.
+        (WebKit::NetworkCache::canStore): Deleted.
+        * NetworkProcess/cache/NetworkCache.h:
+        * NetworkProcess/cache/NetworkCacheStatistics.cpp:
+        (WebKit::NetworkCache::storeDecisionToDiagnosticKey):
+
</ins><span class="cx"> 2015-03-30  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Swipe snapshot removed too early (jumps around) on arstechnica and NYT
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -182,12 +182,10 @@
</span><span class="cx">     return responseHasExpired(response, timestamp, requestDirectives.maxStale);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static UseDecision canUse(const Entry&amp; entry, const WebCore::ResourceRequest&amp; request)
</del><ins>+static UseDecision makeUseDecision(const Entry&amp; entry, const WebCore::ResourceRequest&amp; request)
</ins><span class="cx"> {
</span><del>-    if (!verifyVaryingRequestHeaders(entry.varyingRequestHeaders(), request)) {
-        LOG(NetworkCache, &quot;(NetworkProcess) varying header mismatch\n&quot;);
</del><ins>+    if (!verifyVaryingRequestHeaders(entry.varyingRequestHeaders(), request))
</ins><span class="cx">         return UseDecision::NoDueToVaryingHeaderMismatch;
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     // We never revalidate in the case of a history navigation.
</span><span class="cx">     if (cachePolicyAllowsExpired(request.cachePolicy()))
</span><span class="lines">@@ -196,15 +194,13 @@
</span><span class="cx">     if (!responseNeedsRevalidation(entry.response(), request, entry.timeStamp()))
</span><span class="cx">         return UseDecision::Use;
</span><span class="cx"> 
</span><del>-    bool hasValidatorFields = entry.response().hasCacheValidatorFields();
-    LOG(NetworkCache, &quot;(NetworkProcess) needsRevalidation hasValidatorFields=%d&quot;, hasValidatorFields);
-    if (!hasValidatorFields)
</del><ins>+    if (!entry.response().hasCacheValidatorFields())
</ins><span class="cx">         return UseDecision::NoDueToMissingValidatorFields;
</span><span class="cx"> 
</span><span class="cx">     return UseDecision::Validate;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static RetrieveDecision canRetrieve(const WebCore::ResourceRequest&amp; request)
</del><ins>+static RetrieveDecision makeRetrieveDecision(const WebCore::ResourceRequest&amp; request)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: Support HEAD requests.
</span><span class="cx">     if (request.httpMethod() != &quot;GET&quot;)
</span><span class="lines">@@ -218,6 +214,81 @@
</span><span class="cx">     return RetrieveDecision::Yes;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// http://tools.ietf.org/html/rfc7231#page-48
+static bool isStatusCodeCacheableByDefault(int statusCode)
+{
+    switch (statusCode) {
+    case 200: // OK
+    case 203: // Non-Authoritative Information
+    case 204: // No Content
+    case 300: // Multiple Choices
+    case 301: // Moved Permanently
+    case 404: // Not Found
+    case 405: // Method Not Allowed
+    case 410: // Gone
+    case 414: // URI Too Long
+    case 501: // Not Implemented
+        return true;
+    default:
+        return false;
+    }
+}
+
+static bool isStatusCodePotentiallyCacheable(int statusCode)
+{
+    switch (statusCode) {
+    case 201: // Created
+    case 202: // Accepted
+    case 205: // Reset Content
+    case 302: // Found
+    case 303: // See Other
+    case 307: // Temporary redirect
+    case 403: // Forbidden
+    case 406: // Not Acceptable
+    case 415: // Unsupported Media Type
+        return true;
+    default:
+        return false;
+    }
+}
+
+static StoreDecision makeStoreDecision(const WebCore::ResourceRequest&amp; originalRequest, const WebCore::ResourceResponse&amp; response)
+{
+    if (!originalRequest.url().protocolIsInHTTPFamily() || !response.isHTTP())
+        return StoreDecision::NoDueToProtocol;
+
+    if (originalRequest.httpMethod() != &quot;GET&quot;)
+        return StoreDecision::NoDueToHTTPMethod;
+
+    auto requestDirectives = WebCore::parseCacheControlDirectives(originalRequest.httpHeaderFields());
+    if (requestDirectives.noStore)
+        return StoreDecision::NoDueToNoStoreRequest;
+
+    if (response.cacheControlContainsNoStore())
+        return StoreDecision::NoDueToNoStoreResponse;
+
+    if (!isStatusCodeCacheableByDefault(response.httpStatusCode())) {
+        // http://tools.ietf.org/html/rfc7234#section-4.3.2
+        bool hasExpirationHeaders = std::isfinite(response.expires()) || std::isfinite(response.cacheControlMaxAge());
+        bool expirationHeadersAllowCaching = isStatusCodePotentiallyCacheable(response.httpStatusCode()) &amp;&amp; hasExpirationHeaders;
+        if (!expirationHeadersAllowCaching)
+            return StoreDecision::NoDueToHTTPStatusCode;
+    }
+
+    // Main resource has ResourceLoadPriorityVeryHigh.
+    bool storeUnconditionallyForHistoryNavigation = originalRequest.priority() == WebCore::ResourceLoadPriorityVeryHigh;
+    if (!storeUnconditionallyForHistoryNavigation) {
+        auto currentTime = std::chrono::duration&lt;double&gt;(std::chrono::system_clock::now().time_since_epoch());
+        bool hasNonZeroLifetime = WebCore::computeFreshnessLifetimeForHTTPFamily(response, currentTime.count()) &gt; 0;
+
+        bool possiblyReusable = response.hasCacheValidatorFields() || hasNonZeroLifetime;
+        if (!possiblyReusable)
+            return StoreDecision::NoDueToUnlikelyToReuse;
+    }
+
+    return StoreDecision::Yes;
+}
+
</ins><span class="cx"> void Cache::retrieve(const WebCore::ResourceRequest&amp; originalRequest, uint64_t webPageID, std::function&lt;void (std::unique_ptr&lt;Entry&gt;)&gt; completionHandler)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isEnabled());
</span><span class="lines">@@ -229,7 +300,7 @@
</span><span class="cx">         m_statistics-&gt;recordRetrievalRequest(webPageID);
</span><span class="cx"> 
</span><span class="cx">     Key storageKey = makeCacheKey(originalRequest);
</span><del>-    RetrieveDecision retrieveDecision = canRetrieve(originalRequest);
</del><ins>+    auto retrieveDecision = makeRetrieveDecision(originalRequest);
</ins><span class="cx">     if (retrieveDecision != RetrieveDecision::Yes) {
</span><span class="cx">         if (m_statistics)
</span><span class="cx">             m_statistics-&gt;recordNotUsingCacheForRequest(webPageID, storageKey, originalRequest, retrieveDecision);
</span><span class="lines">@@ -256,7 +327,7 @@
</span><span class="cx"> 
</span><span class="cx">         auto entry = Entry::decodeStorageRecord(*record);
</span><span class="cx"> 
</span><del>-        auto useDecision = entry ? canUse(*entry, originalRequest) : UseDecision::NoDueToDecodeFailure;
</del><ins>+        auto useDecision = entry ? makeUseDecision(*entry, originalRequest) : UseDecision::NoDueToDecodeFailure;
</ins><span class="cx">         switch (useDecision) {
</span><span class="cx">         case UseDecision::Use:
</span><span class="cx">             break;
</span><span class="lines">@@ -279,74 +350,6 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// http://tools.ietf.org/html/rfc7231#page-48
-static bool isStatusCodeCacheableByDefault(int statusCode)
-{
-    switch (statusCode) {
-    case 200: // OK
-    case 203: // Non-Authoritative Information
-    case 204: // No Content
-    case 300: // Multiple Choices
-    case 301: // Moved Permanently
-    case 404: // Not Found
-    case 405: // Method Not Allowed
-    case 410: // Gone
-    case 414: // URI Too Long
-    case 501: // Not Implemented
-        return true;
-    default:
-        return false;
-    }
-}
-
-static bool isStatusCodePotentiallyCacheable(int statusCode)
-{
-    switch (statusCode) {
-    case 201: // Created
-    case 202: // Accepted
-    case 205: // Reset Content
-    case 302: // Found
-    case 303: // See Other
-    case 307: // Temporary redirect
-    case 403: // Forbidden
-    case 406: // Not Acceptable
-    case 415: // Unsupported Media Type
-        return true;
-    default:
-        return false;
-    }
-}
-
-static StoreDecision canStore(const WebCore::ResourceRequest&amp; originalRequest, const WebCore::ResourceResponse&amp; response)
-{
-    if (!originalRequest.url().protocolIsInHTTPFamily() || !response.isHTTP())
-        return StoreDecision::NoDueToProtocol;
-
-    if (originalRequest.httpMethod() != &quot;GET&quot;)
-        return StoreDecision::NoDueToHTTPMethod;
-
-    auto requestDirectives = WebCore::parseCacheControlDirectives(originalRequest.httpHeaderFields());
-    if (requestDirectives.noStore)
-        return StoreDecision::NoDueToNoStoreRequest;
-
-    if (response.cacheControlContainsNoStore())
-        return StoreDecision::NoDueToNoStoreResponse;
-
-    if (isStatusCodeCacheableByDefault(response.httpStatusCode()))
-        return StoreDecision::Yes;
-
-    if (isStatusCodePotentiallyCacheable(response.httpStatusCode())) {
-        // Check for expiration headers allowing us to cache.
-        // http://tools.ietf.org/html/rfc7234#section-4.3.2
-        if (std::isfinite(response.expires()) || std::isfinite(response.cacheControlMaxAge()))
-            return StoreDecision::Yes;
-    }
-
-    LOG(NetworkCache, &quot;(NetworkProcess) status code %d not cacheable by default and no explicit expiration headers&quot;, response.httpStatusCode());
-
-    return StoreDecision::NoDueToHTTPStatusCode;
-}
-
</del><span class="cx"> void Cache::store(const WebCore::ResourceRequest&amp; originalRequest, const WebCore::ResourceResponse&amp; response, RefPtr&lt;WebCore::SharedBuffer&gt;&amp;&amp; responseData, std::function&lt;void (MappedBody&amp;)&gt; completionHandler)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isEnabled());
</span><span class="lines">@@ -354,7 +357,8 @@
</span><span class="cx"> 
</span><span class="cx">     LOG(NetworkCache, &quot;(NetworkProcess) storing %s, partition %s&quot;, originalRequest.url().string().latin1().data(), originalRequest.cachePartition().latin1().data());
</span><span class="cx"> 
</span><del>-    StoreDecision storeDecision = canStore(originalRequest, response);
</del><ins>+    StoreDecision storeDecision = makeStoreDecision(originalRequest, response);
+
</ins><span class="cx">     if (storeDecision != StoreDecision::Yes) {
</span><span class="cx">         LOG(NetworkCache, &quot;(NetworkProcess) didn't store, storeDecision=%d&quot;, storeDecision);
</span><span class="cx">         if (m_statistics) {
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -62,14 +62,16 @@
</span><span class="cx">     NoDueToReloadIgnoringCache
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+// FIXME: This enum is used in the Statistics code in a way that prevents removing or reordering anything.
</ins><span class="cx"> enum class StoreDecision {
</span><span class="cx">     Yes,
</span><span class="cx">     NoDueToProtocol,
</span><span class="cx">     NoDueToHTTPMethod,
</span><del>-    NoDueToAttachmentResponse,
</del><ins>+    NoDueToAttachmentResponse, // Unused.
</ins><span class="cx">     NoDueToNoStoreResponse,
</span><span class="cx">     NoDueToHTTPStatusCode,
</span><del>-    NoDueToNoStoreRequest
</del><ins>+    NoDueToNoStoreRequest,
+    NoDueToUnlikelyToReuse
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> enum class UseDecision {
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheStatisticscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp (182151 => 182152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp        2015-03-30 20:12:19 UTC (rev 182151)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp        2015-03-30 21:09:14 UTC (rev 182152)
</span><span class="lines">@@ -238,6 +238,8 @@
</span><span class="cx">         return WebCore::DiagnosticLoggingKeys::cacheControlNoStoreKey();
</span><span class="cx">     case StoreDecision::NoDueToHTTPStatusCode:
</span><span class="cx">         return WebCore::DiagnosticLoggingKeys::uncacheableStatusCodeKey();
</span><ins>+    case StoreDecision::NoDueToUnlikelyToReuse:
+        return WebCore::DiagnosticLoggingKeys::unlikelyToReuseKey();
</ins><span class="cx">     case StoreDecision::Yes:
</span><span class="cx">         // It was stored but could not be retrieved so it must have been pruned from the cache.
</span><span class="cx">         return WebCore::DiagnosticLoggingKeys::noLongerInCacheKey();
</span></span></pre>
</div>
</div>

</body>
</html>