• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

DEPSH A D16-Feb-2021272 1210

OWNERSH A D16-Feb-2021150 107

README.mdH A D16-Feb-202110.1 KiB198160

appcache.ccH A D16-Feb-202111.9 KiB347286

appcache.hH A D16-Feb-20219.8 KiB256151

appcache_backend_impl.ccH A D16-Feb-20211.7 KiB5037

appcache_backend_impl.hH A D16-Feb-20211.6 KiB5032

appcache_backfillers.ccH A D16-Feb-20216.3 KiB176136

appcache_backfillers.hH A D16-Feb-20213 KiB8632

appcache_browsertest.ccH A D16-Feb-202113.2 KiB328248

appcache_cache_test_helper.ccH A D16-Feb-20218.1 KiB238192

appcache_cache_test_helper.hH A D16-Feb-20213.3 KiB10075

appcache_cache_test_helper_unittest.ccH A D16-Feb-202114.8 KiB421315

appcache_database.ccH A D16-Feb-202140.7 KiB1,2961,013

appcache_database.hH A D16-Feb-202111.6 KiB299241

appcache_database_unittest.ccH A D16-Feb-202143.8 KiB1,197948

appcache_disk_cache.ccH A D16-Feb-202113 KiB397313

appcache_disk_cache.hH A D16-Feb-20215.4 KiB170113

appcache_disk_cache_ops.ccH A D16-Feb-202114.8 KiB493397

appcache_disk_cache_ops.hH A D16-Feb-202110.2 KiB262135

appcache_disk_cache_unittest.ccH A D16-Feb-20217.3 KiB206140

appcache_entry.hH A D16-Feb-20213.5 KiB10265

appcache_fuzzer.ccH A D16-Feb-202111.1 KiB291245

appcache_fuzzer.protoH A D16-Feb-20213.5 KiB157134

appcache_group.ccH A D16-Feb-20218.4 KiB270203

appcache_group.hH A D16-Feb-20217.5 KiB223146

appcache_group_unittest.ccH A D16-Feb-202112.3 KiB332252

appcache_histograms.ccH A D16-Feb-2021459 167

appcache_histograms.hH A D16-Feb-2021576 2312

appcache_host.ccH A D16-Feb-202127.9 KiB755587

appcache_host.hH A D16-Feb-202117.7 KiB447232

appcache_host_unittest.ccH A D16-Feb-202134.7 KiB872650

appcache_internals_ui.ccH A D16-Feb-202120.1 KiB532469

appcache_internals_ui.hH A D16-Feb-20215 KiB135103

appcache_manifest_parser.ccH A D16-Feb-202119.8 KiB578334

appcache_manifest_parser.hH A D16-Feb-20213.2 KiB8437

appcache_manifest_parser_unittest.ccH A D16-Feb-202134.1 KiB849750

appcache_namespace.ccH A D16-Feb-2021872 2815

appcache_namespace.hH A D16-Feb-20211,012 3825

appcache_navigation_handle.ccH A D16-Feb-20212.1 KiB6342

appcache_navigation_handle.hH A D16-Feb-20212.6 KiB7226

appcache_policy.hH A D16-Feb-20211.3 KiB4925

appcache_quota_client.ccH A D16-Feb-20218.9 KiB284226

appcache_quota_client.hH A D16-Feb-20214 KiB10566

appcache_quota_client_unittest.ccH A D16-Feb-202114.5 KiB428322

appcache_request.ccH A D16-Feb-20212.5 KiB8464

appcache_request.hH A D16-Feb-20213.3 KiB11560

appcache_request_handler.ccH A D16-Feb-202125.4 KiB708527

appcache_request_handler.hH A D16-Feb-202110.6 KiB272149

appcache_request_handler_unittest.ccH A D16-Feb-202127.3 KiB796566

appcache_response_info.ccH A D16-Feb-20211.2 KiB4129

appcache_response_info.hH A D16-Feb-20211.7 KiB5839

appcache_response_unittest.ccH A D16-Feb-202130.3 KiB822640

appcache_service_impl.ccH A D16-Feb-202121 KiB645491

appcache_service_impl.hH A D16-Feb-20218.2 KiB228147

appcache_service_unittest.ccH A D16-Feb-202114 KiB395310

appcache_storage.ccH A D16-Feb-20214.8 KiB141114

appcache_storage.hH A D16-Feb-202113.9 KiB362202

appcache_storage_impl.ccH A D16-Feb-202165 KiB1,9541,513

appcache_storage_impl.hH A D16-Feb-20218.1 KiB215155

appcache_storage_impl_unittest.ccH A D16-Feb-202182.2 KiB2,0351,541

appcache_storage_unittest.ccH A D16-Feb-20217.2 KiB193146

appcache_subresource_url_factory.ccH A D16-Feb-202115.4 KiB415331

appcache_subresource_url_factory.hH A D16-Feb-20212.8 KiB7852

appcache_test_helper.ccH A D16-Feb-20212.6 KiB7557

appcache_test_helper.hH A D16-Feb-20211.5 KiB5032

appcache_unittest.ccH A D16-Feb-202123.3 KiB576485

appcache_update_job.ccH A D16-Feb-202168.1 KiB1,7821,335

appcache_update_job.hH A D16-Feb-202112.5 KiB344191

appcache_update_job_state.hH A D16-Feb-2021748 2815

appcache_update_job_unittest.ccH A D16-Feb-2021226.5 KiB5,8474,720

appcache_update_metrics_recorder.ccH A D16-Feb-20213.7 KiB11890

appcache_update_metrics_recorder.hH A D16-Feb-20213.8 KiB9234

appcache_update_url_fetcher.ccH A D16-Feb-20218.5 KiB259202

appcache_update_url_fetcher.hH A D16-Feb-20213.8 KiB12072

appcache_update_url_loader_request.ccH A D16-Feb-20219 KiB281219

appcache_update_url_loader_request.hH A D16-Feb-20216.1 KiB16579

appcache_url_loader.ccH A D16-Feb-202113.7 KiB393297

appcache_url_loader.hH A D16-Feb-20217.9 KiB235127

appcache_working_set.ccH A D16-Feb-20212.4 KiB8264

appcache_working_set.hH A D16-Feb-20212.2 KiB7753

chrome_appcache_service.ccH A D16-Feb-20213.2 KiB9876

chrome_appcache_service.hH A D16-Feb-20213.6 KiB10468

chrome_appcache_service_unittest.ccH A D16-Feb-20217.2 KiB190141

mock_appcache_policy.ccH A D16-Feb-20211.2 KiB4227

mock_appcache_policy.hH A D16-Feb-20211.1 KiB3725

mock_appcache_service.ccH A D16-Feb-2021913 3019

mock_appcache_service.hH A D16-Feb-20211.8 KiB5334

mock_appcache_storage.ccH A D16-Feb-202119.5 KiB560420

mock_appcache_storage.hH A D16-Feb-202111 KiB258211

mock_appcache_storage_unittest.ccH A D16-Feb-202126 KiB643494

test_origin_trial_policy.ccH A D16-Feb-20211.1 KiB3824

test_origin_trial_policy.hH A D16-Feb-2021848 2816

README.md

1# AppCache
2
3AppCache is the well-known shorthand for `Application Cache`, the key mechanism
4in the
5[Offline Web applications specification](https://html.spec.whatwg.org/multipage/offline.html#offline).
6
7*** promo
8AppCache is deprecated and slated for removal from the Web Platform. Chrome's
9implementation is in maintenance mode. We're only tacking critical bugs and code
10health improvements that allow us to reason about bugs easier. Long-term efforts
11should be focused on Service Workers.
12***
13
14
15## Overview
16
17AppCache is aimed at SPAs (single-page Web applications).
18
19The application's HTML page (Document) points to a **manifest** in an `<html
20manifest=...>` attribute. The manifest lists all the sub-resources (style
21sheets, scripts, images, etc.) that the page needs to work offline. When a
22user navigates to the HTML page for the first time, the browser caches all
23the resources in the manifest. Future navigations use the cached resources,
24so the application still works even if the network is down.
25
26The simplified model above misses two critical pieces, which are responsible for
27the bulk of AppCache's complexity. The sections below can be skimmed on a first
28reading.
29
30### Updates (Why AppCache is Hard, Part 1)
31
32The ease of deploying updates is a key strength of Web applications. Browsers
33automatically (barring misconfigured HTTP caching) load the latest version of
34an application's resources when a user navigates to one of the application's
35pages.
36
37AppCache aims for comparable ease by automatically updating its locally cached
38copy of the manifest and its resources whenever a page is visited. This comes
39with some significant caveats:
40
411. AppCache bails early in the update process if the manifest hasn't changed
42   (byte for byte). This behavior is intended to save network bandwidth.
43   The downside is that developers must change their manifest whenever any of
44   the sub-resources change.
452. The manifest does not have any versioning information in it. So, when a
46   manifest changes, the browser must reload all the resources referenced by
47   it.
483. The manifest is only checked for updates when a page is visited, to keep the
49   Web ephemeral. The update check is performed concurrently with page loading,
50   for performance reasons. If the manifest changed, all the resources used
51   by the page are served from the outdated cache. This is necessary, because by
52   the time the browser can detect a manifest update, the page has been
53   partially loaded using the (now known to be outdated) cached resources.
54   It's not reasonable to ask Web developers to support mixing resources from
55   different application versions.
564. While the browser is downloading a page's cache (the manifest and its
57   resources), the user could navigate a different tab to the same page. The
58   second tab uses the result of the ongoing cache download, rather than
59   updating the cache on its own. This removes many race conditions from the
60   cache update process, at the cost of having the browser coordinate between
61   all instances of a page that uses AppCache.
625. AppCache also supports application-driven updates. The support is aimed at
63   applications that may be left open in the same tab for a long time, like
64   e-mail and chat clients. This means browsers must support both
65   navigation-driven cache updates and application-driven updates.
66
67### Multi-Page Applications (Why AppCache is Hard, Part 2)
68
69AppCache supports multi-page applications by allowing multiple pages to share
70the same manifest, and therefore use the same cached resources.
71
72Manifest sharing is particularly complex when combined with implicit caching.
73An AppCache manifest is not required to list the HTML pages that refer to it
74via an `<html manifest>` attribute. (Listing the pages is however recommended.)
75This allowance introduces the following complexities:
76
771. When a browser encounters an HTML page that refers to a manifest it hasn't
78   seen before, the browser creates an implicit resource entry for the HTML
79   page. The HTML page is cached together with the other resources listed in
80   the manifest, so it can be available for offline browsing.
812. When a browser encounters an HTML page that refers to a manifest it has
82   already cached, the browser also creates an implicit resource entry for
83   the HTML page. The existing cache must be changed to include the new
84   implicit resource.
853. When a manifest changes, the browser must update all the implicit resources
86   (HTML pages that refer to the manifest) as well as the resources explicitly
87   mentioned in the manifest. If any of the HTML pages using the manifest are
88   opened, they must be notified that a manifest update is available.
894. When a browser encounters an HTML page that refers to a manifest whose
90   resources are still being downloaded, it needs to ensure that the page's
91   implicit resource eventually gets associated with the manifest. To avoid race
92   conditions, the browser must add the HTML page to a list of pages that need
93   updating. The manifest update logic must also process this list, after
94   downloading the resources already associated with the manifest.
95
96While the pages in multi-page applications can share a manifest, they are not
97required to do so. In other words, an application's pages can use different
98manifests. However, each manifest conceptually spawns its own resource cache,
99which is updated independently from other manifests' caches. So, different pages
100from the same application may use different versions of the same sub-resource,
101if they are associated with different manifests.
102
103A particularly complex case is loading an HTML page that is associated with a
104cached manifest, discovering that the manifest has changed and requires an
105update, updating the HTML page, and obtaining a new version of the HTML page
106that refers to a different manifest. In this case, loading a single page ends up
107downloading two manifests and all the resources associated with them.
108
109
110## Data Model
111
112AppCache uses the following terms:
113
114* A **manifest** is a list of URLs to resources. The listed resources should be
115  be sufficient for the page to be used while offline.
116* An **application cache** contains one version of a manifest and all the
117  resources associated with it. This includes the resources explicitly listed in
118  the manifest, and the implicitly cached HTML pages that refer to the manifest.
119  The HTTP responses are stored in a disk_cache (//net term), then all other
120  AppCache information is stored in a per-profile SQLite database that points
121  into the disk_cache.  The disk_cache scope is per-profile.
122* A **response** represents the headers and body for a given server response.
123  This response is first served by a server and may then be stored and retrieved
124  in the disk_cache.  The application cache in the SQLite database updates each
125  entry to track the associated response id in the disk_cache for that entry.
126* An **application cache group** is a collection of all the application caches
127  that have the same manifest.
128* A **cache host** is a name used to refer to a Document (HTML page) when the
129  emphasis is on the connection between the page, the manifest it references,
130  and the application cache / cache group associated with that manifest.
131
132### Application Cache
133
134An application cache has the following components:
135
1361. **Entries** that identify resources to be cached.
1372. **Namespaces** that direct the loading of sub-resource URLs for a page
138   associated with the cache.
1393. **Flags** that influence the cache's behavior.
140
141All of these components are stored in and retrieved from a SQLite database.
142
143Entries have the following types:
144
145* **manifest** - the AppCache manifest; the absolute URL of this entry is used
146  to identify the group that this application cache belongs to
147* **master** - documents (HTML pages) whose `<html manifest>` attribute points
148  to the cache's manifest; these are added to an application cache as they are
149  discovered during user navigations
150* **explicit** - listed in the manifest's explicit section (`CACHE:`)
151* **fallback** - listed in the manifest's fallback section (`FALLBACK:`)
152
153Explicit and fallback entries can also be marked as **foreign**. A foreign entry
154indicates a document whose `<html manifest>` attribute does not point to this
155cache's manifest.
156
157Each entry can refer to its response, which allows AppCache to know where to
158find a given entry's cached response data in its disk or memory cache.
159
160Namespaces are conceptually patterns that match resource URLs. AppCache supports
161the following namespaces:
162
163* **fallback** - URLs matching the namespace are first fetched from the network.
164  If the fetch fails, a cached fallback resource is used instead. Fallback
165  namespaces are listed in the `FALLBACK:` manifest section.
166* **online safelist** -- URLs matching the namespace are always fetched from the
167  network. Online safelist namespaces are listed in the `NETWORK:` manifest
168  section.
169
170*** promo
171Chrome's AppCache implementation also supports **intercept** namespaces, listed
172in the `CHROMIUM-INTERCEPT:` manifest section. URLs matching an intercept
173namespace are loaded as if the fetch request encountered an HTTP redirect.
174***
175
176The AppCache specification supports specifying namespaces as URL prefixes. Given
177a list of namespaces in an application cache, a resource URL matches the longest
178namespace that is a prefix of the URL.
179
180An application cache has the following flags:
181
182* **completeness** - the application cache is *complete* when all the resources
183  in the manifest have been fetched and cached, and *incomplete* otherwise
184* **online safelist wildcard** - *blocking* by default, which means that all
185  resources not listed in the manifest are considered unavailable; can be set
186  to *open* by adding an `*` entry in the `NETWORK:` manifest section, causing
187  all unlisted resources to be fetched from the network
188* **cache mode** - not supported by Chrome, which does not implement the
189  `SETTINGS:` manifest section
190
191### Historical
192
193Our AppCache implementation supported specifying namespaces as regular
194expressions that match URLs. This extension was invoked by adding the
195`isPattern` keyword after the namespace in the manifest. Support has
196mostly been removed, but a column remains in the database and tests
197validate correct parsing even when it is present.
198