[WK2][NetworkCache] We only cache responses with status codes that are cacheable...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2015 18:24:39 +0000 (18:24 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2015 18:24:39 +0000 (18:24 +0000)
commit7db9eaff91b4a9991a5bd212ed02b50dd767605a
treec1c8d3ff8c84cfe4bb8b4b13513845ef548d39b2
parentd2fbfc151c6b7921be05d6be86bd9dc838363f74
[WK2][NetworkCache] We only cache responses with status codes that are cacheable by default
https://bugs.webkit.org/show_bug.cgi?id=143125
<rdar://problem/20321172>

Reviewed by Antti Koivisto.

Source/WebCore:

Export a couple of extra symbols.

* platform/network/ResourceResponseBase.h:

Source/WebKit2:

We Previously only cached responses with status codes that are cacheable
by default [1]. However, RFC 7234 [2] allows us to cache responses with
other status codes, as long as they have explicit headers allowing
caching:
- 'Expires' header field
- 'max-age' response directive

This patch updates our caching policy accordingly to improve efficiency.

[1] http://tools.ietf.org/html/rfc7231#page-48
[2] http://tools.ietf.org/html/rfc7234#section-4.3.2

Test: http/tests/cache/disk-cache/disk-cache-307-status-code.html

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

LayoutTests:

Add layout test to check that responses with status code 307 (which is not
cacheable by default) are cached if they have explicit expiration headers.

Also update a couple of other disk cache tests to cover heuristic
freshness (http://tools.ietf.org/html/rfc7234#section-4.2.2), relying on
'Last-Modified' header to estimate freshness if usual expiration headers
are not available.

* http/tests/cache/disk-cache/disk-cache-204-status-code-expected.txt:
* http/tests/cache/disk-cache/disk-cache-204-status-code.html:
* http/tests/cache/disk-cache/disk-cache-307-status-code-expected.txt: Added.
* http/tests/cache/disk-cache/disk-cache-307-status-code.html: Added.
* http/tests/cache/disk-cache/disk-cache-404-status-code-expected.txt:
* http/tests/cache/disk-cache/disk-cache-404-status-code.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182071 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/cache/disk-cache/disk-cache-204-status-code-expected.txt
LayoutTests/http/tests/cache/disk-cache/disk-cache-204-status-code.html
LayoutTests/http/tests/cache/disk-cache/disk-cache-307-status-code-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/disk-cache/disk-cache-307-status-code.html [new file with mode: 0644]
LayoutTests/http/tests/cache/disk-cache/disk-cache-404-status-code-expected.txt
LayoutTests/http/tests/cache/disk-cache/disk-cache-404-status-code.html
Source/WebCore/ChangeLog
Source/WebCore/platform/network/ResourceResponseBase.h
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp