⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181734 in webkit


Ignore:
Timestamp:
Mar 19, 2015, 12:54:06 AM (11 years ago)
Author:
Chris Dumez
Message:

The network cache should ignore "cache-control: no-cache, must-revalidate" on history navigation
https://bugs.webkit.org/show_bug.cgi?id=142831
<rdar://problem/20209957>

Reviewed by Antti Koivisto.

Source/WebKit2:

The network cache should ignore "no-cache" and "must-revalidate" as
Cache-Control policy for history navigations to avoid unnecessary
revalidation in this case. Our memory cache already behaves this way.

On history navigation, our disk cache implementation currently
revalidates unconditionally resources if "cache-control: no-cache" is
used. It also revalidates expired resources if "cache-control:
must-revalidate" is used. This is sub-optimal.

RFC 7234 does not require us to do so [1]:
"""

User agents often have history mechanisms, such as "Back" buttons and
history lists, that can be used to redisplay a representation
retrieved earlier in a session.

The freshness model (Section 4.2) does not necessarily apply to
history mechanisms. That is, a history mechanism can display a
previous representation even if it has expired.

"""

Chrome and IE9+ [2] already ignore "cache-control: must-revalidate" on history navigation.

[1] https://tools.ietf.org/html/rfc7234#page-32
[2] http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx

Test: http/tests/cache/disk-cache-validation-back-navigation-policy.html

  • NetworkProcess/cache/NetworkCache.cpp:

(WebKit::NetworkCache::decodeStorageEntry):

LayoutTests:

Rebaseline disk-cache-validation-back-navigation-policy.html test now
that we ignore "cache-control: no-cache, must-revalidate" on history
navigation. This is a progression.

  • http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181732 r181734  
     12015-03-19  Chris Dumez  <cdumez@apple.com>
     2
     3        The network cache should ignore "cache-control: no-cache, must-revalidate" on history navigation
     4        https://bugs.webkit.org/show_bug.cgi?id=142831
     5        <rdar://problem/20209957>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Rebaseline disk-cache-validation-back-navigation-policy.html test now
     10        that we ignore "cache-control: no-cache, must-revalidate" on history
     11        navigation. This is a progression.
     12
     13        * http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt:
     14
    1152015-03-18  Brent Fulgham  <bfulgham@apple.com>
    216
  • trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt

    r181728 r181734  
    2525
    2626response headers: {"Cache-control":"no-cache"}
    27 response source: Network
     27response source: Disk cache
    2828
    2929response headers: {"Cache-control":"max-age=0, no-cache"}
    30 response source: Network
     30response source: Disk cache
    3131
    3232response headers: {"Cache-control":"max-age=100, no-cache"}
    33 response source: Network
     33response source: Disk cache
    3434
    3535response headers: {"ETag":"match"}
     
    5252
    5353response headers: {"Cache-control":"no-cache","ETag":"match"}
    54 response source: Disk cache after validation
     54response source: Disk cache
    5555
    5656response headers: {"Cache-control":"max-age=0, no-cache","ETag":"match"}
    57 response source: Disk cache after validation
     57response source: Disk cache
    5858
    5959response headers: {"Cache-control":"max-age=100, no-cache","ETag":"match"}
    60 response source: Disk cache after validation
     60response source: Disk cache
    6161
    6262response headers: {"ETag":"nomatch"}
     
    7979
    8080response headers: {"Cache-control":"no-cache","ETag":"nomatch"}
    81 response source: Network
     81response source: Disk cache
    8282
    8383response headers: {"Cache-control":"max-age=0, no-cache","ETag":"nomatch"}
    84 response source: Network
     84response source: Disk cache
    8585
    8686response headers: {"Cache-control":"max-age=100, no-cache","ETag":"nomatch"}
    87 response source: Network
     87response source: Disk cache
    8888
    8989response headers: {"Cache-control":"must-revalidate"}
    90 response source: Network
     90response source: Disk cache
    9191
    9292response headers: {"Cache-control":"max-age=0, must-revalidate"}
    93 response source: Network
     93response source: Disk cache
    9494
    9595response headers: {"Cache-control":"max-age=100, must-revalidate"}
     
    106106
    107107response headers: {"Cache-control":"no-cache, must-revalidate"}
    108 response source: Network
     108response source: Disk cache
    109109
    110110response headers: {"Cache-control":"max-age=0, no-cache, must-revalidate"}
    111 response source: Network
     111response source: Disk cache
    112112
    113113response headers: {"Cache-control":"max-age=100, no-cache, must-revalidate"}
    114 response source: Network
     114response source: Disk cache
    115115
    116116response headers: {"ETag":"match","Cache-control":"must-revalidate"}
    117 response source: Disk cache after validation
     117response source: Disk cache
    118118
    119119response headers: {"Cache-control":"max-age=0, must-revalidate","ETag":"match"}
    120 response source: Disk cache after validation
     120response source: Disk cache
    121121
    122122response headers: {"Cache-control":"max-age=100, must-revalidate","ETag":"match"}
     
    133133
    134134response headers: {"Cache-control":"no-cache, must-revalidate","ETag":"match"}
    135 response source: Disk cache after validation
     135response source: Disk cache
    136136
    137137response headers: {"Cache-control":"max-age=0, no-cache, must-revalidate","ETag":"match"}
    138 response source: Disk cache after validation
     138response source: Disk cache
    139139
    140140response headers: {"Cache-control":"max-age=100, no-cache, must-revalidate","ETag":"match"}
    141 response source: Disk cache after validation
     141response source: Disk cache
    142142
    143143response headers: {"ETag":"nomatch","Cache-control":"must-revalidate"}
    144 response source: Network
     144response source: Disk cache
    145145
    146146response headers: {"Cache-control":"max-age=0, must-revalidate","ETag":"nomatch"}
    147 response source: Network
     147response source: Disk cache
    148148
    149149response headers: {"Cache-control":"max-age=100, must-revalidate","ETag":"nomatch"}
     
    160160
    161161response headers: {"Cache-control":"no-cache, must-revalidate","ETag":"nomatch"}
    162 response source: Network
     162response source: Disk cache
    163163
    164164response headers: {"Cache-control":"max-age=0, no-cache, must-revalidate","ETag":"nomatch"}
    165 response source: Network
     165response source: Disk cache
    166166
    167167response headers: {"Cache-control":"max-age=100, no-cache, must-revalidate","ETag":"nomatch"}
    168 response source: Network
     168response source: Disk cache
    169169
    170170PASS successfullyParsed is true
  • trunk/Source/WebKit2/ChangeLog

    r181721 r181734  
     12015-03-19  Chris Dumez  <cdumez@apple.com>
     2
     3        The network cache should ignore "cache-control: no-cache, must-revalidate" on history navigation
     4        https://bugs.webkit.org/show_bug.cgi?id=142831
     5        <rdar://problem/20209957>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        The network cache should ignore "no-cache" and "must-revalidate" as
     10        Cache-Control policy for history navigations to avoid unnecessary
     11        revalidation in this case. Our memory cache already behaves this way.
     12
     13        On history navigation, our disk cache implementation currently
     14        revalidates unconditionally resources if "cache-control: no-cache" is
     15        used. It also revalidates expired resources if "cache-control:
     16        must-revalidate" is used. This is sub-optimal.
     17
     18        RFC 7234 does not require us to do so [1]:
     19        """
     20          User agents often have history mechanisms, such as "Back" buttons and
     21          history lists, that can be used to redisplay a representation
     22          retrieved earlier in a session.
     23
     24          The freshness model (Section 4.2) does not necessarily apply to
     25          history mechanisms.  That is, a history mechanism can display a
     26          previous representation even if it has expired.
     27        """
     28
     29        Chrome and IE9+ [2] already ignore "cache-control: must-revalidate" on history navigation.
     30
     31        [1] https://tools.ietf.org/html/rfc7234#page-32
     32        [2] http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx
     33
     34        Test: http/tests/cache/disk-cache-validation-back-navigation-policy.html
     35
     36        * NetworkProcess/cache/NetworkCache.cpp:
     37        (WebKit::NetworkCache::decodeStorageEntry):
     38
    1392015-03-18  Simon Fraser  <simon.fraser@apple.com>
    240
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

    r181689 r181734  
    207207    }
    208208
    209     bool allowExpired = cachePolicyAllowsExpired(request.cachePolicy()) && !cachedResponse.cacheControlContainsMustRevalidate();
     209    bool allowExpired = cachePolicyAllowsExpired(request.cachePolicy());
    210210    auto timeStamp = std::chrono::duration_cast<std::chrono::duration<double>>(storageEntry.timeStamp);
    211211    double age = WebCore::computeCurrentAge(cachedResponse, timeStamp.count());
    212212    double lifetime = WebCore::computeFreshnessLifetimeForHTTPFamily(cachedResponse, timeStamp.count());
    213213    bool isExpired = age > lifetime;
    214     bool needsRevalidation = (isExpired && !allowExpired) || cachedResponse.cacheControlContainsNoCache();
     214    // We never revalidate in the case of a history navigation (i.e. allowExpired is true).
     215    bool needsRevalidation = !allowExpired && (cachedResponse.cacheControlContainsNoCache() || isExpired);
    215216
    216217    if (needsRevalidation) {
Note: See TracChangeset for help on using the changeset viewer.