105
8. For eachtaskp842
intask list,queue that task as a post-load taskp820
.
9. Abort theapplication cache download processp814
.
9. Letnew cachebe a newly createdapplication cachep807
incache group. Set itscompleteness flagp808
toincomplete.
10. For each entry incache group'slist of pending master entriesp808
, associate theDocumentp103
for this entry withnew cache.
11. Set thestatusp808
ofcache grouptodownloading.
12. For eachcache hostp808
associated with anapplication cachep807
incache group,queue a post-load taskp820
tofire a simple eventp854
that is cancelable nameddownloadingp807
at theApplicationCachep822
singleton of thecache hostp808
. The default action of these
events must be, if the user agentshows caching progressp814
, the display of some sort of user interface indicating to the user that a new
version is being downloaded.
13. Letfile listbe an empty list of URLs with flags.
14. Add all the URLs in the list ofexplicit entriesp807
obtained by parsingmanifesttofile list, each flagged with "explicit entry".
15. Add all the URLs in the list offallback entriesp807
obtained by parsingmanifesttofile list, each flagged with "fallback entry".
16. If this is anupgrade attemptp815
, then add all the URLs ofmaster entriesp807
in thenewestp808
application cachep807
incache group
whosecompleteness flagp808
iscompletetofile list, each flagged with "master entry".
17. If any URL is infile listmore than once, then merge the entries into one entry for that URL, that entry having all the flags that the original
entries had.
18. For each URL infile list, run the following steps. These steps may be run in parallel for two or more of the URLs at a time. If, while
running these steps, theApplicationCachep822
object'sabort()p824
methodsends a signalp824
to this instance of theapplication
cache download processp814
algorithm, then run thecache failure stepsp819
instead.
1. If the resource URL being processed was flagged as neither an "explicit entry" nor or a "fallback entry", then the user agent
may skip this URL.
2. For eachcache hostp808
associated with anapplication cachep807
incache group,queue a progress post-load taskp820
to
firep44
atrustedp44
event with the nameprogressp807
, which does not bubble, which is cancelable, and which uses the
ProgressEvent
interface, at theApplicationCachep822
singleton of thecache hostp808
. ThelengthComputable
attribute must be set to true, thetotal
attribute must be set to the number of files infile list, and theloaded
attribute must
be set to the number of files infile listthat have been either downloaded or skipped so far. The default action of these events
must be, if the user agentshows caching progressp814
, the display of some sort of user interface indicating to the user that a
file is being downloaded in preparation for updating the application.[XHR]p1165
3. Letrequestbe a newrequest
whoseurl
is URL,client
is null,destination
is "subresource",origin
ismanifest URL's
originp767
,referrer
is "no-referrer",synchronous flag
is set,credentials mode
is "include",use-URL-credentials flag
is
set, andredirect mode
is "manual".
4. Fetch
request. If this is anupgrade attemptp815
, then use thenewestp808
application cachep807
incache groupas an HTTP
cache, and honor HTTP caching semantics (such as expiration, ETags, and so forth) with respect to that cache. User agents
may also have other caches in place that are also honored.
5. If the previous step fails (e.g. the server returns a 4xx or 5xx response, or there is a DNS error, or the connection times out,
or the user cancels the download), or if the server returned a redirect, or if the resource is labeled with the "no-store" cache
directive, then run the first appropriate step from the following list:[HTTP]p1160
↪
If the URL being processed was flagged as an "explicit entry" or a "fallback entry"
If these steps are being run in parallel for any other URLs infile list, then abort these steps for those other URLs.
Run thecache failure stepsp819
.
This is intended to allow user agents to expire resources not listed in the manifest from the cache. Generally,
implementors are urged to use an approach that expires lesser-used resources first.
Note
Redirects are fatal because they are either indicative of a network problem (e.g. a captive portal); or
would allow resources to be added to the cache under URLs that differ from any URL that the networking
model will allow access to, leaving orphan entries; or would allow resources to be stored under URLs
different than their true URLs. All of these situations are bad.
Note
817
90
↪
If the error was a 404 or 410 HTTP response
↪
If the resource was labeled with the "no-store" cache directive
Skip this resource. It is dropped from the cache.
↪
Otherwise
Copy the resource and its metadata from thenewestp808
application cachep807
incache groupwhose
completeness flagp808
iscomplete, and act as if that was the fetched resource, ignoring the resource obtained from
the network.
User agents may warn the user of these errors as an aid to development.
6. Otherwise, the fetching succeeded. Store the resource in thenew cache.
If the user agent is not able to store the resource (e.g. because of quota restrictions), the user agent may prompt the user or
try to resolve the problem in some other manner (e.g. automatically pruning content in other caches). If the problem cannot
be resolved, the user agent must run thecache failure stepsp819
.
7. If the URL being processed was flagged as an "explicit entry" infile list, then categorise the entry as anexplicit entryp807
.
8. If the URL being processed was flagged as a "fallback entry" infile list, then categorise the entry as afallback entryp807
.
9. If the URL being processed was flagged as an "master entry" infile list, then categorise the entry as amaster entryp807
.
10. As an optimization, if the resource is an HTML or XML file whosedocument element
is anhtmlp134
element with a
manifestp134
attribute whose value doesn't match the manifest URL of the application cache being processed, then the
user agent should mark the entry as beingforeignp807
.
19. For eachcache hostp808
associated with anapplication cachep807
incache group,queue a progress post-load taskp820
tofirep44
a
trustedp44
event with the nameprogressp807
, which does not bubble, which is cancelable, and which uses theProgressEvent
interface, at theApplicationCachep822
singleton of thecache hostp808
. ThelengthComputable
attribute must be set to true, the
total
and theloaded
attributes must be set to the number of files infile list. The default action of these events must be, if the user
agentshows caching progressp814
, the display of some sort of user interface indicating to the user that all the files have been
downloaded.[XHR]p1165
20. Store the list offallback namespacesp807
, and the URLs of thefallback entriesp807
that they map to, innew cache.
21. Store the URLs that form the newonline safelistp807
innew cache.
22. Store the value of the newonline safelist wildcard flagp808
innew cache.
23. Store the value of the newcache mode flagp808
innew cache.
24. For each entry incache group'slist of pending master entriesp808
, wait for the resource for this entry to have either completely
downloaded or failed.
If the download failed (e.g. the server returns a 4xx or 5xx response, or there is a DNS error, the connection times out, or the user
cancels the download), or if the resource is labeled with the "no-store" cache directive, then run these substeps:
1. Unassociate theDocumentp103
for this entry fromnew cache.
2. Queue a post-load taskp820
tofire a simple eventp854
that is cancelable namederrorp807
at theApplicationCachep822
singleton of theDocumentp103
for this entry, if there still is one. The default action of this event must be, if the user agent
shows caching progressp814
, the display of some sort of user interface indicating to the user that the user agent failed to save
the application for offline use.
3. If this is acache attemptp815
and this entry is the last entry incache group'slist of pending master entriesp808
, then run these
further substeps:
1. Discardcache groupand its onlyapplication cachep807
,new cache.
These rules make errors for resources listed in the manifest fatal, while making it possible for other resources to be
removed from caches when they are removed from the server, without errors, and making non-manifest resources
survive server-side errors.
Note
Except for the "no-store" directive, HTTP caching rules that would cause a file to be expired or otherwise not cached
are ignored for the purposes of theapplication cache download processp814
.
Note
818
104
2. If appropriate, remove any user interface indicating that an update for this cache is in progress.
3. Abort theapplication cache download processp814
.
4. Otherwise, remove this entry fromcache group'slist of pending master entriesp808
.
Otherwise, store the resource for this entry innew cache, if it isn't already there, and categorise its entry as amaster entryp807
.
25. Letrequestbe a newrequest
whoseurl
ismanifest URL,client
is null,destination
is "subresource",referrer
is "no-referrer",
synchronous flag
is set,credentials mode
is "include", and whoseuse-URL-credentials flag
is set.
26. Letsecond manifestbe the result offetching
request. HTTP caching semantics should again be honored for this request.
27. If the previous step failed for any reason, or if the fetching attempt involved a redirect, or ifsecond manifestandmanifestare not byte-
for-byte identical, then schedule a rerun of the entire algorithm with the same parameters after a short delay, and run thecache failure
stepsp819
.
28. Otherwise, storemanifestinnew cache, if it's not there already, and categorise its entry asthe manifestp807
.
29. Set thecompleteness flagp808
ofnew cachetocomplete.
30. Lettask listbe an empty list oftasksp842
.
31. If this is acache attemptp815
, then for eachcache hostp808
associated with anapplication cachep807
incache group, create ataskp842
to
fire a simple eventp854
that is cancelable namedcachedp807
at theApplicationCachep822
singleton of thecache hostp808
, and append
it totask list. The default action of these events must be, if the user agentshows caching progressp814
, the display of some sort of user
interface indicating to the user that the application has been cached and that they can now use it offline.
Otherwise, it is anupgrade attemptp815
. For eachcache hostp808
associated with anapplication cachep807
incache group, create a
taskp842
tofire a simple eventp854
that is cancelable namedupdatereadyp807
at theApplicationCachep822
singleton of thecache
hostp808
, and append it totask list. The default action of these events must be, if the user agentshows caching progressp814
, the display
of some sort of user interface indicating to the user that a new version is available and that they can activate it by reloading the page.
32. If appropriate, remove any user interface indicating that an update for this cache is in progress.
33. Set theupdate statusp808
ofcache grouptoidle.
34. For eachtaskp842
intask list,queue that task as a post-load taskp820
.
Thecache failure stepsare as follows:
1. Lettask listbe an empty list oftasksp842
.
2. For each entry incache group'slist of pending master entriesp808
, run the following further substeps. These steps may be run in parallel
for two or more entries at a time.
1. Wait for the resource for this entry to have either completely downloaded or failed.
2. Unassociate theDocumentp103
for this entry from itsapplication cachep807
, if it has one.
3. Create ataskp842
tofire a simple eventp854
that is cancelable namederrorp807
at theApplicationCachep822
singleton of
theDocumentp103
for this entry, if there still is one, and append it totask list. The default action of these events must be, if
the user agentshows caching progressp814
, the display of some sort of user interface indicating to the user that the user
agent failed to save the application for offline use.
3. For eachcache hostp808
still associated with anapplication cachep807
incache group, create ataskp842
tofire a simple eventp854
that is
cancelable namederrorp807
at theApplicationCachep822
singleton of thecache hostp808
, and append it totask list. The default
action of these events must be, if the user agentshows caching progressp814
, the display of some sort of user interface indicating to the
user that the user agent failed to save the application for offline use.
4. Emptycache group'slist of pending master entriesp808
.
5. Ifcache grouphas anapplication cachep807
whosecompleteness flagp808
isincomplete, then discard thatapplication cachep807
.
Since caching can be honored, authors are encouraged to avoid setting the cache headers on the manifest in such a way that
the user agent would simply not contact the network for this second request; otherwise, the user agent would not notice if the
cache had changed during the cache update process.
Note
819
74
6. If appropriate, remove any user interface indicating that an update for this cache is in progress.
7. Let thestatusp808
ofcache groupbeidle.
8. If this was acache attemptp815
, discardcache groupaltogether.
9. For eachtaskp842
intask list,queue that task as a post-load taskp820
.
10. Abort theapplication cache download processp814
.
Attempts to fetch resources as part of theapplication cache download processp814
may be done with cache-defeating semantics, to avoid problems
with stale or inconsistent intermediary caches.
User agents may invoke theapplication cache download processp814
, in the background, for anyapplication cache groupp808
, at any time (with no
cache hostp808
). This allows user agents to keep caches primed and to update caches even before the user visits a site.
EachDocumentp103
has a list ofpending application cache download process tasksthat is used to delay events fired by the algorithm above
until the document'sloadp1154
event has fired. When theDocumentp103
is created, the list must be empty.
When the steps above say toqueue a post-load tasktask, wheretaskis ataskp842
that dispatches an event on a targetApplicationCachep822
objecttarget, the user agent must run the appropriate steps from the following list:
Iftarget'snode document
isready for post-load tasksp1042
Queuep843
the tasktask.
Otherwise
Addtasktotarget'snode document
's list ofpending application cache download process tasksp820
.
When the steps above say toqueue a progress post-load tasktask, wheretaskis ataskp842
that dispatches an event on a target
ApplicationCachep822
objecttarget, the user agent must run the following steps:
1. If there is ataskintarget'snode document
's list ofpending application cache download process tasksp820
that is labeled as aprogress
task, then remove that task from the list.
2. Labeltaskas aprogress task.
3. Queue a post-load taskp820
task.
Thetask sourcep843
for thesetasksp842
is thenetworking task sourcep846
.
When theapplication cache selection algorithmalgorithm is invoked with aDocumentp103
documentand optionally a manifestURL
manifest
URL, the user agent must run the first applicable set of steps from the following list:
↪
If there is amanifest URL, anddocumentwas loaded from anapplication cachep807
, and the URL of themanifestp807
of that cache's
application cache groupp808
isnotthe same asmanifest URL
Mark the entry for the resource from whichdocumentwas taken in theapplication cachep807
from which it was loaded asforeignp807
.
Restart the current navigation from the top of thenavigation algorithmp788
, undoing any changes that were made as part of the initial load
(changes can be avoided by ensuring that the step toupdate the session history with the new pagep794
is only ever completedafterthis
application cache selection algorithmp820
is run, though this is not required).
User agents may notify the user of the inconsistency between the cache manifest and the document's own metadata, to aid in application
development.
The navigation will not result in the same resource being loaded, because "foreign" entries are never picked during navigation.
Note
7.9.5 The application cache selection algorithm
820
Documents you may be interested
Documents you may be interested