Implement Cache-control: immutable
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2017 18:44:18 +0000 (18:44 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2017 18:44:18 +0000 (18:44 +0000)
commitba91783411f05463a2a440cbe5f54f0187552177
tree9948c3e6df73610269b29cbf85fadbc6ef910ea3
parent586f1a2733f883956e70bc58b498ae7f522101f5
Implement Cache-control: immutable
https://bugs.webkit.org/show_bug.cgi?id=167497

Reviewed by Chris Dumez.

Source/WebCore:

Cache-control value 'immutable' indicates that a subresource does not change and so does not need to be
revalidated on a normal reload. This can significantly speed up reloads and reduce network traffic.

It is has been implemented in Firefox and is already used by Facebook.

https://tools.ietf.org/html/draft-mcmanus-immutable-00
https://hacks.mozilla.org/2017/01/using-immutable-caching-to-speed-up-the-web/

This patch implements Cache-control: immutable for memory cache only. A disk cache implementation
doesn't seem necessary as the resource is basically always expected to be in memory cache on reload.

Immutable is only supported for https as suggested by the draft specification (and Gecko implementation).

Test: http/tests/cache/cache-control-immutable-http.html
      http/tests/cache/cache-control-immutable-https.html

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::makeRevalidationDecision):

    On normal reloads (CachePolicyRevalidate) of https resources check for 'Cache-control: immutable'.
    If the resource is not expired don't revalidate it.

* platform/network/CacheValidation.cpp:
(WebCore::parseCacheControlDirectives):
* platform/network/CacheValidation.h:
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::cacheControlContainsImmutable):
* platform/network/ResourceResponseBase.h:

LayoutTests:

* http/tests/cache/cache-control-immutable-http-expected.txt: Added.
* http/tests/cache/cache-control-immutable-http.html: Added.
* http/tests/cache/cache-control-immutable-https-expected.txt: Added.
* http/tests/cache/cache-control-immutable-https.html: Added.
* http/tests/cache/resources/cache-control-immutable.js: Added.
* http/tests/cache/resources/iframe-with-script.cgi: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache/cache-control-immutable-http-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/cache-control-immutable-http.html [new file with mode: 0644]
LayoutTests/http/tests/cache/cache-control-immutable-https-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/cache-control-immutable-https.html [new file with mode: 0644]
LayoutTests/http/tests/cache/resources/cache-control-immutable.js [new file with mode: 0644]
LayoutTests/http/tests/cache/resources/iframe-with-script.cgi [new file with mode: 0755]
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/platform/network/CacheValidation.cpp
Source/WebCore/platform/network/CacheValidation.h
Source/WebCore/platform/network/ResourceResponseBase.cpp
Source/WebCore/platform/network/ResourceResponseBase.h