Modified: trunk/LayoutTests/ChangeLog (184836 => 184837)
--- trunk/LayoutTests/ChangeLog 2015-05-24 03:14:09 UTC (rev 184836)
+++ trunk/LayoutTests/ChangeLog 2015-05-24 03:15:00 UTC (rev 184837)
@@ -1,3 +1,15 @@
+2015-05-23 Antti Koivisto <[email protected]>
+
+ Permanent redirects should have long implicit cache lifetime
+ https://bugs.webkit.org/show_bug.cgi?id=145348
+
+ Reviewed by Sam Weinig.
+
+ * http/tests/cache/cache-redirections.html:
+ * http/tests/cache/resources/cache-control-redirect.php:
+
+ Use less confusing name (max_age->expiration vs. max-age) and fix logic.
+
2015-05-23 Zalan Bujtas <[email protected]>
Rebaseline after r184825. Remove artificial extra space between 2 text renderers.
Modified: trunk/LayoutTests/http/tests/cache/cache-redirections.html (184836 => 184837)
--- trunk/LayoutTests/http/tests/cache/cache-redirections.html 2015-05-24 03:14:09 UTC (rev 184836)
+++ trunk/LayoutTests/http/tests/cache/cache-redirections.html 2015-05-24 03:15:00 UTC (rev 184837)
@@ -22,6 +22,10 @@
{name : "Should reload resource (no-cache redirection)", expected : false, url: baseURL + "&cache_control=no-cache&max_age=1000", reloadDelay : 0},
{name : "Should reload resource (must-revalidate redirection)", expected : false, url: baseURL + "&cache_control=must-revalidate&max_age=1000", reloadDelay : 0},
{name : "Should reload resource (expired redirection)", expected : false, url: baseURL + "&cache_control=public, max-age=1", reloadDelay : 1000},
+{name : "Should reload resource (implicit expiration)", expected : false, url: baseURL + "", reloadDelay : 100},
+{name : "Should reuse resource (301 cacheable redirection)", expected : true, url : baseURL + "&code=301&cache_control=public, max-age=1000", reloadDelay : 0},
+{name : "Should reuse resource (301 no-store redirection)", expected : false, url : baseURL + "&code=301&cache_control=no-store", reloadDelay : 0},
+{name : "Should reuse resource (301 implicit expiration)", expected : true, url: baseURL + "&code=301", reloadDelay : 100},
];
function loadResource()
Modified: trunk/LayoutTests/http/tests/cache/resources/cache-control-redirect.php (184836 => 184837)
--- trunk/LayoutTests/http/tests/cache/resources/cache-control-redirect.php 2015-05-24 03:14:09 UTC (rev 184836)
+++ trunk/LayoutTests/http/tests/cache/resources/cache-control-redirect.php 2015-05-24 03:15:00 UTC (rev 184837)
@@ -16,9 +16,9 @@
else
header('Location: ' . $url);
- $max_age = $_GET['max_age'];
- if (!isset($max_age)) {
- $expires = gmdate(DATE_RFC1123, time() + $max_age);
+ $expiration = $_GET['expiration'];
+ if (isset($expiration)) {
+ $expires = gmdate(DATE_RFC1123, time() + $expiration);
header('Expires: ' . $expires);
}
Modified: trunk/Source/WebCore/ChangeLog (184836 => 184837)
--- trunk/Source/WebCore/ChangeLog 2015-05-24 03:14:09 UTC (rev 184836)
+++ trunk/Source/WebCore/ChangeLog 2015-05-24 03:15:00 UTC (rev 184837)
@@ -1,3 +1,21 @@
+2015-05-23 Antti Koivisto <[email protected]>
+
+ Permanent redirects should have long implicit cache lifetime
+ https://bugs.webkit.org/show_bug.cgi?id=145348
+ rdar://problem/20680519
+
+ Reviewed by Sam Weinig.
+
+ 301 Moved Permanently response that doesn't specify explicit lifetime should have long implicit lifetime.
+ This matches other browsers.
+
+ * platform/network/CacheValidation.cpp:
+ (WebCore::computeFreshnessLifetimeForHTTPFamily):
+
+ Give 301 Moved Permanently (and similarly semantically permanent 410 Gone) long implicit lifetime.
+
+ (WebCore::updateRedirectChainStatus):
+
2015-05-23 Myles C. Maxfield <[email protected]>
Cleanup after r184796
Modified: trunk/Source/WebCore/platform/network/CacheValidation.cpp (184836 => 184837)
--- trunk/Source/WebCore/platform/network/CacheValidation.cpp 2015-05-24 03:14:09 UTC (rev 184836)
+++ trunk/Source/WebCore/platform/network/CacheValidation.cpp 2015-05-24 03:15:00 UTC (rev 184837)
@@ -120,14 +120,20 @@
if (expires)
return duration_cast<microseconds>(expires.value() - dateValue);
- // Heuristic Freshness:
- // http://tools.ietf.org/html/rfc7234#section-4.2.2
- auto lastModified = response.lastModified();
- if (lastModified)
- return duration_cast<microseconds>((dateValue - lastModified.value()) * 0.1);
-
- // If no cache headers are present, the specification leaves the decision to the UA. Other browsers seem to opt for 0.
- return microseconds::zero();
+ // Implicit lifetime.
+ switch (response.httpStatusCode()) {
+ case 301: // Moved Permanently
+ case 410: // Gone
+ // These are semantically permanent and so get long implicit lifetime.
+ return hours(365 * 24);
+ default:
+ // Heuristic Freshness:
+ // http://tools.ietf.org/html/rfc7234#section-4.2.2
+ auto lastModified = response.lastModified();
+ if (lastModified)
+ return duration_cast<microseconds>((dateValue - lastModified.value()) * 0.1);
+ return microseconds::zero();
+ }
}
void updateRedirectChainStatus(RedirectChainCacheStatus& redirectChainCacheStatus, const ResourceResponse& response)