Back to Chromium

Cache sharing for extremely-pervasive resources

services/network/pervasive_resources/README.md

149.0.7827.23.0 KB
Original Source

Cache sharing for extremely-pervasive resources

This directory contains the core of the logic for determining if a request is for a pervasive resource as part of the implementation for cache sharing for extremely-pervasive resources.

Feature Overview

For a select list of resources that have been determined to be safe and in extremely-wide use, Chrome can choose to store them in a single-keyed HTTP cache.

List generation

The list of URLPatterns for pervasive resources is generated by analyzing the HTTP archive for resources with the following criteria:

  1. Each URLPattern must represent a resource that was used on over 100,000 pages in the archive for each of the last 6 months.
  2. Only include resources that responded with cache-control: public and did not have a set-cookie response header.
  3. Only include requests that are for script and style destinations as well as and compression dictionaries.
  4. Resources loaded with query parameters are excluded.
  5. Each match pattern refers to a single resource. This can be a static URL where the same URL is always used or a URLPattern that covers multiple URLs that only differ by a hash, version string and/or language.

The full list must not exceed 500 entries.

Criteria for using the single-keyed cache

In order to protect the user from privacy and security risks, the single-keyed cache can only be used when all of the following conditions are met for a request:

  1. Full cookie access is allowed between the document and the request (including third-party cookies being enabled).
  2. The fetch destination must be script, style or compression-dictionary.
  3. The request must not include query parameters.
  4. The request must not include the VALIDATE_CACHE, BYPASS_CACHE, SKIP_CACHE_VALIDATION, DISABLE_CACHE, or ONLY_FROM_CACHE load flags.
  5. For each URLPattern, only two unique URLs are allowed to match within any given one-hour window.
  6. The top-level document that the request is associated with must have initiated a request from user interaction within the last ten minutes.
  7. The request matches a URLPattern in the list of pervasive resources.
  8. The response must include cache-control: public.

For the last requirement, the cache isolation key has already been selected by the time the response headers are available so, in that case, the response will not be written to cache.

For all other requirements, the conditions can be checked at the time that the request is made and when a cache isolation key is generated.

For requests that do not meet the criteria, they fall through to using the normal triple-keyed HTTP cache.

List expiration

The list of URLPatterns includes an expiration date for when the list is no longer considered "fresh" and should be ignored.