You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2366 lines
141 KiB
2366 lines
141 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html lang="en-US-x-Hixie" ><head><title>5.6 Offline Web applications — HTML5 </title><style type="text/css">
|
|
pre { margin-left: 2em; white-space: pre-wrap; }
|
|
h2 { margin: 3em 0 1em 0; }
|
|
h3 { margin: 2.5em 0 1em 0; }
|
|
h4 { margin: 2.5em 0 0.75em 0; }
|
|
h5, h6 { margin: 2.5em 0 1em; }
|
|
h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
|
|
h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
|
|
p { margin: 1em 0; }
|
|
hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
|
|
dl, dd { margin-top: 0; margin-bottom: 0; }
|
|
dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
|
|
dt + dt { margin-top: 0; }
|
|
dd dt { margin-top: 0.25em; margin-bottom: 0; }
|
|
dd p { margin-top: 0; }
|
|
dd dl + p { margin-top: 1em; }
|
|
dd table + p { margin-top: 1em; }
|
|
p + * > li, dd li { margin: 1em 0; }
|
|
dt, dfn { font-weight: bold; font-style: normal; }
|
|
dt dfn { font-style: italic; }
|
|
pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
|
|
pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
|
|
pre em { font-weight: bolder; font-style: normal; }
|
|
@media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
|
|
var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
|
|
table { border-collapse: collapse; border-style: hidden hidden none hidden; }
|
|
table thead, table tbody { border-bottom: solid; }
|
|
table tbody th:first-child { border-left: solid; }
|
|
table tbody th { text-align: left; }
|
|
table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
|
|
blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
|
|
|
|
.bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
|
|
.matrix, .matrix td { border: none; text-align: right; }
|
|
.matrix { margin-left: 2em; }
|
|
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
|
|
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
|
|
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
|
|
|
|
.toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
|
|
img.extra { float: right; }
|
|
pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
|
|
pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
|
|
pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
|
|
pre.css:first-line { color: #AAAA50; }
|
|
dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
|
|
hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
|
|
dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
|
|
dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
|
|
dl.domintro dd p { margin: 0.5em 0; }
|
|
dl.switch { padding-left: 2em; }
|
|
dl.switch > dt { text-indent: -1.5em; }
|
|
dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
|
|
dl.triple { padding: 0 0 0 1em; }
|
|
dl.triple dt, dl.triple dd { margin: 0; display: inline }
|
|
dl.triple dt:after { content: ':'; }
|
|
dl.triple dd:after { content: '\A'; white-space: pre; }
|
|
.diff-old { text-decoration: line-through; color: silver; background: transparent; }
|
|
.diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
|
|
a .diff-new { border-bottom: 1px blue solid; }
|
|
|
|
h2 { page-break-before: always; }
|
|
h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
|
|
h1 + h2, hr + h2.no-toc { page-break-before: auto; }
|
|
|
|
p > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
|
|
li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]), { border-bottom: solid #9999CC; }
|
|
|
|
div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
|
|
div.head p { margin: 0; }
|
|
div.head h1 { margin: 0; }
|
|
div.head .logo { float: right; margin: 0 1em; }
|
|
div.head .logo img { border: none } /* remove border from top image */
|
|
div.head dl { margin: 1em 0; }
|
|
div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
|
|
|
|
body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
|
|
body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
|
|
body > .toc > li > * { margin-bottom: 0.5em; }
|
|
body > .toc > li > * > li > * { margin-bottom: 0.25em; }
|
|
.toc, .toc li { list-style: none; }
|
|
|
|
.brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
|
|
.brief li { margin: 0; padding: 0; }
|
|
.brief li p { margin: 0; padding: 0; }
|
|
|
|
.category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
|
|
.category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
|
|
.category-list li { display: inline; }
|
|
.category-list li:not(:last-child)::after { content: ', '; }
|
|
.category-list li > span, .category-list li > a { text-transform: lowercase; }
|
|
.category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
|
|
|
|
.XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
|
|
.XXX > :first-child { margin-top: 0; }
|
|
p .XXX { line-height: 3em; }
|
|
.annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
|
|
.annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
|
|
.annotation :link, .annotation :visited { color: inherit; }
|
|
.annotation :link:hover, .annotation :visited:hover { background: transparent; }
|
|
.annotation span { border: none ! important; }
|
|
.note { color: green; background: transparent; font-family: sans-serif; }
|
|
.warning { color: red; background: transparent; }
|
|
.note, .warning { font-weight: bolder; font-style: italic; }
|
|
p.note, div.note { padding: 0.5em 2em; }
|
|
span.note { padding: 0 2em; }
|
|
.note p:first-child, .warning p:first-child { margin-top: 0; }
|
|
.note p:last-child, .warning p:last-child { margin-bottom: 0; }
|
|
.warning:before { font-style: normal; }
|
|
p.note:before { content: 'Note: '; }
|
|
p.warning:before { content: '\26A0 Warning! '; }
|
|
|
|
.bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
|
|
.bookkeeping { font-size: 0.8em; margin: 2em 0; }
|
|
.bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
|
|
.bookkeeping dt { margin: 0.5em 2em 0; }
|
|
.bookkeeping dd { margin: 0 3em 0.5em; }
|
|
|
|
h4 { position: relative; z-index: 3; }
|
|
h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
|
|
.element {
|
|
background: #EEEEFF;
|
|
color: black;
|
|
margin: 0 0 1em 0.15em;
|
|
padding: 0 1em 0.25em 0.75em;
|
|
border-left: solid #9999FF 0.25em;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
.element:before {
|
|
position: absolute;
|
|
z-index: 2;
|
|
top: 0;
|
|
left: -1.15em;
|
|
height: 2em;
|
|
width: 0.9em;
|
|
background: #EEEEFF;
|
|
content: ' ';
|
|
border-style: none none solid solid;
|
|
border-color: #9999FF;
|
|
border-width: 0.25em;
|
|
}
|
|
|
|
.example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
|
|
td > .example:only-child { margin: 0 0 0 0.1em; }
|
|
|
|
ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
|
|
ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
|
|
ul.domTree li li { list-style: none; }
|
|
ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
|
|
ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
|
|
ul.domTree span { font-style: italic; font-family: serif; }
|
|
ul.domTree .t1 code { color: purple; font-weight: bold; }
|
|
ul.domTree .t2 { font-style: normal; font-family: monospace; }
|
|
ul.domTree .t2 .name { color: black; font-weight: bold; }
|
|
ul.domTree .t2 .value { color: blue; font-weight: normal; }
|
|
ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
|
|
ul.domTree .t7 code, .domTree .t8 code { color: green; }
|
|
ul.domTree .t10 code { color: teal; }
|
|
|
|
body.dfnEnabled dfn { cursor: pointer; }
|
|
.dfnPanel {
|
|
display: inline;
|
|
position: absolute;
|
|
z-index: 10;
|
|
height: auto;
|
|
width: auto;
|
|
padding: 0.5em 0.75em;
|
|
font: small sans-serif, Droid Sans Fallback;
|
|
background: #DDDDDD;
|
|
color: black;
|
|
border: outset 0.2em;
|
|
}
|
|
.dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
|
|
.dfnPanel :link, .dfnPanel :visited { color: black; }
|
|
.dfnPanel p { font-weight: bolder; }
|
|
.dfnPanel * + p { margin-top: 0.25em; }
|
|
.dfnPanel li { list-style-position: inside; }
|
|
|
|
#configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
|
|
#configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
|
|
#configUI p label { display: block; }
|
|
#configUI #updateUI, #configUI .loginUI { text-align: center; }
|
|
#configUI input[type=button] { display: block; margin: auto; }
|
|
|
|
fieldset { margin: 1em; padding: 0.5em 1em; }
|
|
fieldset > legend + * { margin-top: 0; }
|
|
fieldset > :last-child { margin-bottom: 0; }
|
|
fieldset p { margin: 0.5em 0; }
|
|
|
|
.stability {
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0; right: 0;
|
|
margin: 0 auto 0 auto !important;
|
|
z-index: 1000;
|
|
width: 50%;
|
|
background: maroon; color: yellow;
|
|
-webkit-border-radius: 1em 1em 0 0;
|
|
-moz-border-radius: 1em 1em 0 0;
|
|
border-radius: 1em 1em 0 0;
|
|
-moz-box-shadow: 0 0 1em #500;
|
|
-webkit-box-shadow: 0 0 1em #500;
|
|
box-shadow: 0 0 1em red;
|
|
padding: 0.5em 1em;
|
|
text-align: center;
|
|
}
|
|
.stability strong {
|
|
display: block;
|
|
}
|
|
.stability input {
|
|
appearance: none; margin: 0; border: 0; padding: 0.25em 0.5em; background: transparent; color: black;
|
|
position: absolute; top: -0.5em; right: 0; font: 1.25em sans-serif; text-align: center;
|
|
}
|
|
.stability input:hover {
|
|
color: white;
|
|
text-shadow: 0 0 2px black;
|
|
}
|
|
.stability input:active {
|
|
padding: 0.3em 0.45em 0.2em 0.55em;
|
|
}
|
|
.stability :link, .stability :visited,
|
|
.stability :link:hover, .stability :visited:hover {
|
|
background: transparent;
|
|
color: white;
|
|
}
|
|
|
|
</style><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation
|
|
requirements"><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css"><style type="text/css">
|
|
|
|
.applies thead th > * { display: block; }
|
|
.applies thead code { display: block; }
|
|
.applies tbody th { whitespace: nowrap; }
|
|
.applies td { text-align: center; }
|
|
.applies .yes { background: yellow; }
|
|
|
|
.matrix, .matrix td { border: hidden; text-align: right; }
|
|
.matrix { margin-left: 2em; }
|
|
|
|
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
|
|
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
|
|
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
|
|
|
|
td.eg { border-width: thin; text-align: center; }
|
|
|
|
#table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
|
|
#table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
|
|
#table-example-1 caption { padding-bottom: 0.5em; }
|
|
#table-example-1 thead, #table-example-1 tbody { border: none; }
|
|
#table-example-1 th, #table-example-1 td { border: solid thin; }
|
|
#table-example-1 th { font-weight: normal; }
|
|
#table-example-1 td { border-style: none solid; vertical-align: top; }
|
|
#table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
|
|
#table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
|
|
#table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
|
|
#table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
|
|
#table-example-1 tbody td:first-child::after { content: leader(". "); }
|
|
#table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
|
|
#table-example-1 tbody td:first-child + td { width: 10em; }
|
|
#table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
|
|
#table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
|
|
|
|
.apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
|
|
.apple-table-examples * { font-family: "Times", serif; }
|
|
.apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
|
|
.apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
|
|
.apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
|
|
.apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
|
|
.apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
|
|
.apple-table-examples td { text-align: right; vertical-align: top; }
|
|
.apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
|
|
.apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
|
|
.apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
|
|
.apple-table-examples sup { line-height: 0; }
|
|
|
|
.details-example img { vertical-align: top; }
|
|
|
|
#base64-table {
|
|
white-space: nowrap;
|
|
font-size: 0.6em;
|
|
column-width: 6em;
|
|
column-count: 5;
|
|
column-gap: 1em;
|
|
-moz-column-width: 6em;
|
|
-moz-column-count: 5;
|
|
-moz-column-gap: 1em;
|
|
-webkit-column-width: 6em;
|
|
-webkit-column-count: 5;
|
|
-webkit-column-gap: 1em;
|
|
}
|
|
#base64-table thead { display: none; }
|
|
#base64-table * { border: none; }
|
|
#base64-table tbody td:first-child:after { content: ':'; }
|
|
#base64-table tbody td:last-child { text-align: right; }
|
|
|
|
#named-character-references-table {
|
|
white-space: nowrap;
|
|
font-size: 0.6em;
|
|
column-width: 30em;
|
|
column-gap: 1em;
|
|
-moz-column-width: 30em;
|
|
-moz-column-gap: 1em;
|
|
-webkit-column-width: 30em;
|
|
-webkit-column-gap: 1em;
|
|
}
|
|
#named-character-references-table > table > tbody > tr > td:first-child + td,
|
|
#named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
|
|
#named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
|
|
#named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
|
|
|
|
.glyph.control { color: red; }
|
|
|
|
@font-face {
|
|
font-family: 'Essays1743';
|
|
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
|
|
}
|
|
@font-face {
|
|
font-family: 'Essays1743';
|
|
font-weight: bold;
|
|
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
|
|
}
|
|
@font-face {
|
|
font-family: 'Essays1743';
|
|
font-style: italic;
|
|
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
|
|
}
|
|
@font-face {
|
|
font-family: 'Essays1743';
|
|
font-style: italic;
|
|
font-weight: bold;
|
|
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
|
|
}
|
|
|
|
</style><style type="text/css">
|
|
.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
|
|
</style><script type="text/javascript">
|
|
function getCookie(name) {
|
|
var params = location.search.substr(1).split("&");
|
|
for (var index = 0; index < params.length; index++) {
|
|
if (params[index] == name)
|
|
return "1";
|
|
var data = params[index].split("=");
|
|
if (data[0] == name)
|
|
return unescape(data[1]);
|
|
}
|
|
var cookies = document.cookie.split("; ");
|
|
for (var index = 0; index < cookies.length; index++) {
|
|
var data = cookies[index].split("=");
|
|
if (data[0] == name)
|
|
return unescape(data[1]);
|
|
}
|
|
return null;
|
|
}
|
|
</script>
|
|
<script src="link-fixup.js" type="text/javascript"></script>
|
|
<link href="style.css" rel="stylesheet"><link href="history.html" title="5.4 Session history and navigation" rel="prev">
|
|
<link href="spec.html#contents" title="Table of contents" rel="index">
|
|
<link href="webappapis.html" title="6 Web application APIs" rel="next">
|
|
</head><body><div class="head" id="head">
|
|
<div id="multipage-common">
|
|
<p class="stability" id="wip"><strong>This is a work in
|
|
progress!</strong> For the latest updates from the HTML WG, possibly
|
|
including important bug fixes, please look at the <a href="http://dev.w3.org/html5/spec/Overview.html">editor's draft</a> instead.
|
|
There may also be a more
|
|
<a href="http://www.w3.org/TR/html5">up-to-date Working Draft</a>
|
|
with changes based on resolution of Last Call issues.
|
|
<input onclick="closeWarning(this.parentNode)" type="button" value="╳⃝"></p>
|
|
<script type="text/javascript">
|
|
function closeWarning(element) {
|
|
element.parentNode.removeChild(element);
|
|
var date = new Date();
|
|
date.setDate(date.getDate()+4);
|
|
document.cookie = 'hide-obsolescence-warning=1; expires=' + date.toGMTString();
|
|
}
|
|
if (getCookie('hide-obsolescence-warning') == '1')
|
|
setTimeout(function () { document.getElementById('wip').parentNode.removeChild(document.getElementById('wip')); }, 2000);
|
|
</script></div>
|
|
|
|
<p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
|
|
|
|
<h1>HTML5</h1>
|
|
</div><div>
|
|
<a href="history.html" class="prev">5.4 Session history and navigation</a> –
|
|
<a href="spec.html#contents">Table of contents</a> –
|
|
<a href="webappapis.html" class="next">6 Web application APIs</a>
|
|
<ol class="toc"><li><ol><li><a href="offline.html#offline"><span class="secno">5.6 </span>Offline Web applications</a>
|
|
<ol><li><a href="offline.html#introduction-4"><span class="secno">5.6.1 </span>Introduction</a>
|
|
<ol><li><a href="offline.html#appcacheevents"><span class="secno">5.6.1.1 </span>Event summary</a></li></ol></li><li><a href="offline.html#appcache"><span class="secno">5.6.2 </span>Application caches</a></li><li><a href="offline.html#manifests"><span class="secno">5.6.3 </span>The cache manifest syntax</a>
|
|
<ol><li><a href="offline.html#some-sample-manifests"><span class="secno">5.6.3.1 </span>Some sample manifests</a></li><li><a href="offline.html#writing-cache-manifests"><span class="secno">5.6.3.2 </span>Writing cache manifests</a></li><li><a href="offline.html#parsing-cache-manifests"><span class="secno">5.6.3.3 </span>Parsing cache manifests</a></li></ol></li><li><a href="offline.html#downloading-or-updating-an-application-cache"><span class="secno">5.6.4 </span>Downloading or updating an application cache</a></li><li><a href="offline.html#the-application-cache-selection-algorithm"><span class="secno">5.6.5 </span>The application cache selection algorithm</a></li><li><a href="offline.html#changesToNetworkingModel"><span class="secno">5.6.6 </span>Changes to the networking model</a></li><li><a href="offline.html#expiring-application-caches"><span class="secno">5.6.7 </span>Expiring application caches</a></li><li><a href="offline.html#disk-space"><span class="secno">5.6.8 </span>Disk space</a></li><li><a href="offline.html#application-cache-api"><span class="secno">5.6.9 </span>Application cache API</a></li><li><a href="offline.html#browser-state"><span class="secno">5.6.10 </span>Browser state</a></li></ol></li></ol></li></ol></div>
|
|
|
|
<h3 id="offline"><span class="secno">5.6 </span>Offline Web applications</h3><h4 id="introduction-4"><span class="secno">5.6.1 </span>Introduction</h4><p><i>This section is non-normative.</i></p><p>In order to enable users to continue interacting with Web
|
|
applications and documents even when their network connection is
|
|
unavailable — for instance, because they are traveling outside
|
|
of their ISP's coverage area — authors can provide a manifest
|
|
which lists the files that are needed for the Web application to
|
|
work offline and which causes the user's browser to keep a copy of
|
|
the files for use offline.</p><p>To illustrate this, consider a simple clock applet consisting of
|
|
an HTML page "<code title="">clock.html</code>", a CSS style sheet
|
|
"<code title="">clock.css</code>", and a JavaScript script "<code title="">clock.js</code>".</p><p>Before adding the manifest, these three files might look like
|
|
this:</p><pre><!-- clock.html -->
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Clock</title>
|
|
<script src="clock.js"></script>
|
|
<link rel="stylesheet" href="clock.css">
|
|
</head>
|
|
<body>
|
|
<p>The time is: <output id="clock"></output></p>
|
|
</body>
|
|
</html></pre><pre>/* clock.css */
|
|
output { font: 2em sans-serif; }</pre><pre>/* clock.js */
|
|
setTimeout(function () {
|
|
document.getElementById('clock').value = new Date();
|
|
}, 1000);</pre><p>If the user tries to open the "<code title="">clock.html</code>"
|
|
page while offline, though, the user agent (unless it happens to
|
|
have it still in the local cache) will fail with an error.</p><p>The author can instead provide a manifest of the three files:</p><pre>CACHE MANIFEST
|
|
clock.html
|
|
clock.css
|
|
clock.js</pre><p>With a small change to the HTML file, the manifest (served as
|
|
<code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code>) is linked to the application:</p><pre><!-- clock.html -->
|
|
<!DOCTYPE HTML>
|
|
<html manifest="clock.appcache">
|
|
<head>
|
|
<title>Clock</title>
|
|
<script src="clock.js"></script>
|
|
<link rel="stylesheet" href="clock.css">
|
|
</head>
|
|
<body>
|
|
<p>The time is: <output id="clock"></output></p>
|
|
</body>
|
|
</html></pre><p>Now, if the user goes to the page, the browser will cache the
|
|
files and make them available even when the user is offline.</p><p class="note">Authors are encouraged to include the main page in
|
|
the manifest also, but in practice the page that referenced the
|
|
manifest is automatically cached even if it isn't explicitly
|
|
mentioned.</p><p class="note">HTTP cache headers and restrictions on caching pages
|
|
served over TLS (encrypted, using <code title="">https:</code>) are
|
|
overridden by manifests. Thus, pages will not expire from an
|
|
application cache before the user agent has updated it, and even
|
|
applications served over TLS can be made to work offline.</p><h5 id="appcacheevents"><span class="secno">5.6.1.1 </span>Event summary</h5><p><i>This section is non-normative.</i></p><p>When the user visits a page that declares a manifest, the browser
|
|
will try to update the cache. It does this by fetching a copy of the
|
|
manifest and, if the manifest has changed since the user agent last
|
|
saw it, redownloading all the resources it mentions and caching them
|
|
anew.</p><p>As this is going on, a number of events get fired on the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> object to keep the script updated as
|
|
to the state of the cache update, so that the user can be notified
|
|
appropriately. The events are as follows:</p><table><thead><tr><th> Event name
|
|
</th><th> Interface
|
|
</th><th> Dispatched when...
|
|
</th><th> Next events
|
|
</th></tr></thead><tbody><tr><td> <dfn id="event-appcache-checking" title="event-appcache-checking"><code>checking</code></dfn>
|
|
</td><td> <code><a href="infrastructure.html#event">Event</a></code>
|
|
</td><td> The user agent is checking for an update, or attempting to download the manifest for the first time. <strong>This is always the first event in the sequence.</strong>
|
|
</td><td> <code title="event-appcache-noupdate"><a href="#event-appcache-noupdate">noupdate</a></code>, <code title="event-appcache-downloading"><a href="#event-appcache-downloading">downloading</a></code>, <code title="event-appcache-obsolete"><a href="#event-appcache-obsolete">obsolete</a></code>, <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code>
|
|
</td></tr><tr><td> <dfn id="event-appcache-noupdate" title="event-appcache-noupdate"><code>noupdate</code></dfn>
|
|
</td><td> <code><a href="infrastructure.html#event">Event</a></code>
|
|
</td><td> The manifest hadn't changed.
|
|
</td><td> Last event in sequence.
|
|
</td></tr><tr><td> <dfn id="event-appcache-downloading" title="event-appcache-downloading"><code>downloading</code></dfn>
|
|
</td><td> <code><a href="infrastructure.html#event">Event</a></code>
|
|
</td><td> The user agent has found an update and is fetching it, or is downloading the resources listed by the manifest for the first time.
|
|
</td><td> <code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>, <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code>, <code title="event-appcache-cached"><a href="#event-appcache-cached">cached</a></code>, <code title="event-appcache-updateready"><a href="#event-appcache-updateready">updateready</a></code>
|
|
</td></tr><tr><td> <dfn id="event-appcache-progress" title="event-appcache-progress"><code>progress</code></dfn>
|
|
</td><td> <code>ProgressEvent</code>
|
|
</td><td> The user agent is downloading resources listed by the manifest.
|
|
</td><td> <code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>, <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code>, <code title="event-appcache-cached"><a href="#event-appcache-cached">cached</a></code>, <code title="event-appcache-updateready"><a href="#event-appcache-updateready">updateready</a></code>
|
|
</td></tr><tr><td> <dfn id="event-appcache-cached" title="event-appcache-cached"><code>cached</code></dfn>
|
|
</td><td> <code><a href="infrastructure.html#event">Event</a></code>
|
|
</td><td> The resources listed in the manifest have been downloaded, and the application is now cached.
|
|
</td><td> Last event in sequence.
|
|
</td></tr><tr><td> <dfn id="event-appcache-updateready" title="event-appcache-updateready"><code>updateready</code></dfn>
|
|
</td><td> <code><a href="infrastructure.html#event">Event</a></code>
|
|
</td><td> The resources listed in the manifest have been newly redownloaded, and the script can use <code title="dom-appcache-swapCache"><a href="#dom-appcache-swapcache">swapCache()</a></code> to switch to the new cache.
|
|
</td><td> Last event in sequence.
|
|
</td></tr><tr><td> <dfn id="event-appcache-obsolete" title="event-appcache-obsolete"><code>obsolete</code></dfn>
|
|
</td><td> <code><a href="infrastructure.html#event">Event</a></code>
|
|
</td><td> The manifest was found to have become a 404 or 410 page, so the application cache is being deleted.
|
|
</td><td> Last event in sequence.
|
|
</td></tr><tr><td rowspan="4"> <dfn id="event-appcache-error" title="event-appcache-error"><code>error</code></dfn>
|
|
</td><td rowspan="4"> <code><a href="infrastructure.html#event">Event</a></code>
|
|
</td><td> The manifest was a 404 or 410 page, so the attempt to cache the application has been aborted.
|
|
</td><td rowspan="3"> Last event in sequence.
|
|
</td></tr><tr><td> The manifest hadn't changed, but the page referencing the manifest failed to download properly.
|
|
</td></tr><tr><td> A fatal error occurred while fetching the resources listed in the manifest.
|
|
</td></tr><tr><td> The manifest changed while the update was being run.
|
|
</td><td> The user agent will try fetching the files again momentarily.
|
|
</td></tr></tbody></table><div class="impl">
|
|
|
|
<h4 id="appcache"><span class="secno">5.6.2 </span>Application caches</h4>
|
|
|
|
<p>An <dfn id="application-cache">application cache</dfn> is a set of cached resources
|
|
consisting of:</p>
|
|
|
|
<ul><li>
|
|
|
|
<p>One or more resources (including their out-of-band metadata,
|
|
such as HTTP headers, if any), identified by URLs, each falling
|
|
into one (or more) of the following categories:</p>
|
|
|
|
<dl><dt><dfn id="concept-appcache-master" title="concept-appcache-master">Master entries</dfn>
|
|
|
|
</dt><dd><p class="note">These are documents that were added to the
|
|
cache because a <a href="browsers.html#browsing-context">browsing context</a> was <a href="history.html#navigate" title="navigate">navigated</a> to that document and the
|
|
document indicated that this was its cache, using the <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute.</p>
|
|
|
|
|
|
</dd><dt><dfn id="concept-appcache-manifest" title="concept-appcache-manifest">The manifest</dfn>
|
|
|
|
</dt><dd><p class="note">This is the resource corresponding to the URL
|
|
that was given in a master entry's <code><a href="semantics.html#the-html-element">html</a></code> element's
|
|
<code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute. The
|
|
manifest is fetched and processed during the <a href="#application-cache-download-process">application
|
|
cache download process</a>. All the <a href="#concept-appcache-master" title="concept-appcache-master">master entries</a> have the
|
|
<a href="origin-0.html#same-origin" title="same origin">same origin</a> as the manifest.</p>
|
|
|
|
|
|
</dd><dt><dfn id="concept-appcache-explicit" title="concept-appcache-explicit">Explicit entries</dfn>
|
|
|
|
</dt><dd><p class="note">These are the resources that were listed in
|
|
the cache's <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> in an <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit
|
|
section</a>.</p>
|
|
|
|
|
|
</dd><dt><dfn id="concept-appcache-fallback" title="concept-appcache-fallback">Fallback entries</dfn>
|
|
|
|
</dt><dd><p class="note">These are the resources that were listed in
|
|
the cache's <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> in a <a href="#concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback
|
|
section</a>.</p>
|
|
|
|
|
|
</dd></dl><p><a href="#concept-appcache-explicit" title="concept-appcache-explicit">Explicit entries</a>
|
|
and <a href="#concept-appcache-fallback" title="concept-appcache-fallback">Fallback
|
|
entries</a> can be marked as <dfn id="concept-appcache-foreign" title="concept-appcache-foreign">foreign</dfn>, which means that
|
|
they have a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code>
|
|
attribute but that it doesn't point at this cache's <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a>.</p>
|
|
|
|
<p class="note">A URL in the list can be flagged with multiple
|
|
different types, and thus an entry can end up being categorized as
|
|
multiple entries. For example, an entry can be a manifest entry
|
|
and an explicit entry at the same time, if the manifest is listed
|
|
within the manifest.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>Zero or more <dfn id="concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
|
|
namespaces</dfn>, each of which is mapped to a <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entry</a>.</p>
|
|
|
|
<p class="note">These are URLs used as <a href="#concept-appcache-matches-fallback" title="concept-appcache-matches-fallback">prefix match
|
|
patterns</a> for resources that are to be fetched from the
|
|
network if possible, or to be replaced by the corresponding <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entry</a> if not.
|
|
Each namespace URL has the <a href="origin-0.html#same-origin">same origin</a> as <a href="#concept-appcache-manifest" title="concept-appcache-manifest">the manifest</a>.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>Zero or more URLs that form the <dfn id="concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
|
|
namespaces</dfn>.</p>
|
|
|
|
<p class="note">These are used as prefix match patterns, and
|
|
declare URLs that the user agent will never load from the cache
|
|
but will instead always attempt to obtain from the network.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>An <dfn id="concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
|
|
wildcard flag</dfn>, which is either <i title="">open</i> or <i title="">blocking</i>.</p>
|
|
|
|
<p class="note">The <i title="">open</i> state indicates that any
|
|
URL not listed as cached is to be implicitly treated as being in
|
|
the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online
|
|
whitelist namespaces</a>; the <i title="">blocking</i> state
|
|
indicates that URLs not listed explicitly in the manifest are to
|
|
be treated as unavailable.</p>
|
|
|
|
</li>
|
|
|
|
</ul><p>Each <a href="#application-cache">application cache</a> has a <dfn id="concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</dfn>, which is
|
|
either <i>complete</i> or <i>incomplete</i>.</p>
|
|
|
|
<hr><p>An <dfn id="application-cache-group">application cache group</dfn> is a group of <a href="#application-cache" title="application cache">application caches</a>, identified by
|
|
the <a href="urls.html#absolute-url">absolute URL</a> of a resource <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> which is used to
|
|
populate the caches in the group.</p>
|
|
|
|
<p>An <a href="#application-cache">application cache</a> is <dfn id="concept-appcache-newer" title="concept-appcache-newer">newer</dfn> than another if it was
|
|
created after the other (in other words, <a href="#application-cache" title="application
|
|
cache">application caches</a> in an <a href="#application-cache-group">application cache
|
|
group</a> have a chronological order).</p>
|
|
|
|
<p>Only the newest <a href="#application-cache">application cache</a> in an
|
|
<a href="#application-cache-group">application cache group</a> can have its <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> set to
|
|
<i>incomplete</i>; the others are always all <i>complete</i>.</p>
|
|
|
|
<p>Each <a href="#application-cache-group">application cache group</a> has an <dfn id="concept-appcache-status" title="concept-appcache-status">update status</dfn>, which is one of
|
|
the following: <i>idle</i>, <i>checking</i>, <i>downloading</i>.</p>
|
|
|
|
<p>A <dfn id="relevant-application-cache">relevant application cache</dfn> is an <a href="#application-cache">application
|
|
cache</a> that is the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> in its <a href="#application-cache-group" title="application cache group">group</a> to be
|
|
<i>complete</i>.</p>
|
|
|
|
<p>Each <a href="#application-cache-group">application cache group</a> has a <dfn id="concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</dfn>. Each entry in this list consists of a resource and a
|
|
corresponding <code><a href="infrastructure.html#document">Document</a></code> object. It is used during the
|
|
<a href="#application-cache-download-process">application cache download process</a> to ensure that new
|
|
master entries are cached even if the <a href="#application-cache-download-process">application cache
|
|
download process</a> was already running for their
|
|
<a href="#application-cache-group">application cache group</a> when they were loaded.</p>
|
|
|
|
<p>An <a href="#application-cache-group">application cache group</a> can be marked as <dfn id="concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</dfn>, meaning that it
|
|
must be ignored when looking at what <a href="#application-cache-group" title="application cache
|
|
group">application cache groups</a> exist.</p>
|
|
|
|
<hr><p>A <dfn id="cache-host">cache host</dfn> is a <code><a href="infrastructure.html#document">Document</a></code> or a
|
|
<code>SharedWorkerGlobalScope</code> object. A <a href="#cache-host">cache
|
|
host</a> can be associated with an <a href="#application-cache">application
|
|
cache</a>.
|
|
|
|
<a href="references.html#refsWEBWORKERS">[WEBWORKERS]</a>
|
|
|
|
</p>
|
|
|
|
<p>A <code><a href="infrastructure.html#document">Document</a></code> initially is not associated with an
|
|
<a href="#application-cache">application cache</a>, but can become associated with one
|
|
early during the page load process, when steps <a href="tree-construction.html#parser-appcache">in the parser</a> and in the <a href="history.html#navigate" title="navigate">navigation</a> sections cause <a href="#concept-appcache-init" title="concept-appcache-init">cache selection</a> to occur.</p>
|
|
|
|
<p>A <code>SharedWorkerGlobalScope</code> can be associated with an
|
|
<a href="#application-cache">application cache</a> when it is created.
|
|
|
|
<a href="references.html#refsWEBWORKERS">[WEBWORKERS]</a>
|
|
|
|
</p>
|
|
|
|
<p>Each <a href="#cache-host">cache host</a> has an associated
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> object.</p>
|
|
|
|
<hr><p>Multiple <a href="#application-cache" title="application cache">application
|
|
caches</a> in different <a href="#application-cache-group" title="application cache
|
|
group">application cache groups</a> can contain the same
|
|
resource, e.g. if the manifests all reference that resource. If the
|
|
user agent is to <dfn id="concept-appcache-selection" title="concept-appcache-selection">select an
|
|
application cache</dfn> from a list of <a href="#relevant-application-cache" title="relevant
|
|
application cache">relevant application caches</a> that contain a
|
|
resource, the user agent must use the application cache that the
|
|
user most likely wants to see the resource from, taking into account
|
|
the following:</p>
|
|
|
|
<ul><li>which application cache was most recently updated,
|
|
|
|
</li><li>which application cache was being used to display the
|
|
resource from which the user decided to look at the new resource,
|
|
and
|
|
|
|
</li><li>which application cache the user prefers.
|
|
|
|
</li></ul><hr><p>A URL <dfn id="concept-appcache-matches-fallback" title="concept-appcache-matches-fallback">matches a
|
|
fallback namespace</dfn> if there exists a <a href="#relevant-application-cache">relevant
|
|
application cache</a> whose <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a>'s URL has the
|
|
<a href="origin-0.html#same-origin">same origin</a> as the URL in question, and that has a
|
|
<a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>
|
|
that is a <a href="infrastructure.html#prefix-match">prefix match</a> for the URL being examined. If
|
|
multiple fallback namespaces match the same URL, the longest one is
|
|
the one that matches. A URL looking for a fallback namespace can
|
|
match more than one application cache at a time, but only matches
|
|
one namespace in each cache.</p>
|
|
|
|
<div class="example">
|
|
|
|
<p>If a manifest <code title="">http://example.com/app1/manifest</code> declares that
|
|
<code title="">http://example.com/resources/images</code> is a
|
|
fallback namespace, and the user navigates to <code title="">HTTP://EXAMPLE.COM:80/resources/images/cat.png</code>,
|
|
then the user agent will decide that the application cache
|
|
identified by <code title="">http://example.com/app1/manifest</code> contains a
|
|
namespace with a match for that URL.</p>
|
|
|
|
|
|
</div>
|
|
|
|
</div><h4 id="manifests"><span class="secno">5.6.3 </span>The cache manifest syntax</h4><h5 id="some-sample-manifests"><span class="secno">5.6.3.1 </span>Some sample manifests</h5><p><i>This section is non-normative.</i></p><div class="example">
|
|
|
|
<p>This example manifest requires two images and a style sheet to be
|
|
cached and whitelists a CGI script.</p>
|
|
|
|
<pre>CACHE MANIFEST
|
|
# the above line is required
|
|
|
|
# this is a comment
|
|
# there can be as many of these anywhere in the file
|
|
# they are all ignored
|
|
# comments can have spaces before them
|
|
# but must be alone on the line
|
|
|
|
# blank lines are ignored too
|
|
|
|
# these are files that need to be cached they can either be listed
|
|
# first, or a "CACHE:" header could be put before them, as is done
|
|
# lower down.
|
|
images/sound-icon.png
|
|
images/background.png
|
|
# note that each file has to be put on its own line
|
|
|
|
# here is a file for the online whitelist -- it isn't cached, and
|
|
# references to this file will bypass the cache, always hitting the
|
|
# network (or trying to, if the user is offline).
|
|
NETWORK:
|
|
comm.cgi
|
|
|
|
# here is another set of files to cache, this time just the CSS file.
|
|
CACHE:
|
|
style/default.css</pre>
|
|
|
|
<p>It could equally well be written as follows:</p>
|
|
|
|
<pre>CACHE MANIFEST
|
|
NETWORK:
|
|
comm.cgi
|
|
CACHE:
|
|
style/default.css
|
|
images/sound-icon.png
|
|
images/background.png</pre>
|
|
|
|
</div><div class="example">
|
|
|
|
<p>Offline application cache manifests can use absolute paths or
|
|
even absolute URLs:</p>
|
|
|
|
<pre>CACHE MANIFEST
|
|
|
|
/main/home
|
|
/main/app.js
|
|
/settings/home
|
|
/settings/app.js
|
|
http://img.example.com/logo.png
|
|
http://img.example.com/check.png
|
|
http://img.example.com/cross.png</pre>
|
|
|
|
</div><div class="example">
|
|
|
|
<p>The following manifest defines a catch-all error page that is
|
|
displayed for any page on the site while the user is offline. It
|
|
also specifies that the <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
|
|
wildcard flag</a> is <i title="">open</i>, meaning that accesses
|
|
to resources on other sites will not be blocked. (Resources on the
|
|
same site are already not blocked because of the catch-all fallback
|
|
namespace.)</p>
|
|
|
|
<p>So long as all pages on the site reference this manifest, they
|
|
will get cached locally as they are fetched, so that subsequent hits
|
|
to the same page will load the page immediately from the
|
|
cache. Until the manifest is changed, those pages will not be
|
|
fetched from the server again. When the manifest changes, then all
|
|
the files will be redownloaded.</p>
|
|
|
|
<p>Subresources, such as style sheets, images, etc, would only be
|
|
cached using the regular HTTP caching semantics, however.</p>
|
|
|
|
<pre>CACHE MANIFEST
|
|
FALLBACK:
|
|
/ /offline.html
|
|
NETWORK:
|
|
*</pre>
|
|
|
|
</div><h5 id="writing-cache-manifests"><span class="secno">5.6.3.2 </span>Writing cache manifests</h5><p>Manifests must be served using the
|
|
<code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code> <a href="infrastructure.html#mime-type">MIME type</a>. All
|
|
resources served using the <code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code>
|
|
<a href="infrastructure.html#mime-type">MIME type</a> must follow the syntax of application cache
|
|
manifests, as described in this section.</p><p>An application cache manifest is a text file, whose text is
|
|
encoded using UTF-8. Data in application cache manifests is
|
|
line-based. Newlines must be represented by U+000A LINE FEED (LF)
|
|
characters, U+000D CARRIAGE RETURN (CR) characters, or U+000D
|
|
CARRIAGE RETURN (CR) U+000A LINE FEED (LF) pairs. <a href="references.html#refsRFC3629">[RFC3629]</a></p><p class="note">This is a <a href="introduction.html#willful-violation">willful violation</a> of RFC
|
|
2046, which requires all <code title="">text/*</code> types to only
|
|
allow CRLF line breaks. This requirement, however, is outdated; the
|
|
use of CR, LF, and CRLF line breaks is commonly supported and indeed
|
|
sometimes CRLF is <em>not</em> supported by text editors. <a href="references.html#refsRFC2046">[RFC2046]</a></p><p>The first line of an application cache manifest must consist of
|
|
the string "CACHE", a single U+0020 SPACE character, the string
|
|
"MANIFEST", and either a U+0020 SPACE character, a U+0009 CHARACTER
|
|
TABULATION (tab) character, a U+000A LINE FEED (LF) character, or a
|
|
U+000D CARRIAGE RETURN (CR) character. The first line may optionally
|
|
be preceded by a U+FEFF BYTE ORDER MARK (BOM) character. If any
|
|
other text is found on the first line, it is ignored.</p><p>Subsequent lines, if any, must all be one of the following:</p><dl><dt>A blank line
|
|
</dt><dd>
|
|
<p>Blank lines must consist of zero or more U+0020 SPACE and
|
|
U+0009 CHARACTER TABULATION (tab) characters only.</p>
|
|
|
|
</dd><dt>A comment
|
|
</dt><dd>
|
|
<p>Comment lines must consist of zero or more U+0020 SPACE and
|
|
U+0009 CHARACTER TABULATION (tab) characters, followed by a single
|
|
U+0023 NUMBER SIGN character (#), followed by zero or more
|
|
characters other than U+000A LINE FEED (LF) and U+000D CARRIAGE
|
|
RETURN (CR) characters.</p>
|
|
|
|
<p class="note">Comments must be on a line on their own. If they
|
|
were to be included on a line with a URL, the "#" would be
|
|
mistaken for part of a fragment identifier.</p>
|
|
|
|
</dd><dt>A section header
|
|
</dt><dd>
|
|
<p>Section headers change the current section. There are three
|
|
possible section headers:
|
|
|
|
</p><dl><dt><code>CACHE:</code>
|
|
</dt><dd>Switches to the <dfn id="concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit section</dfn>.
|
|
|
|
</dd><dt><code>FALLBACK:</code>
|
|
</dt><dd>Switches to the <dfn id="concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback section</dfn>.
|
|
|
|
</dd><dt><code>NETWORK:</code>
|
|
</dt><dd>Switches to the <dfn id="concept-appcache-manifest-network" title="concept-appcache-manifest-network">online whitelist section</dfn>.
|
|
|
|
</dd></dl><p>Section header lines must consist of zero or more U+0020 SPACE
|
|
and U+0009 CHARACTER TABULATION (tab) characters, followed by one
|
|
of the names above (including the U+003A COLON character (:))
|
|
followed by zero or more U+0020 SPACE and U+0009 CHARACTER
|
|
TABULATION (tab) characters.</p>
|
|
|
|
<p>Ironically, by default, the current section is the
|
|
<a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit section</a>.</p>
|
|
|
|
</dd><dt>Data for the current section
|
|
</dt><dd>
|
|
<p>The format that data lines must take depends on the current
|
|
section.</p>
|
|
|
|
<p>When the current section is the <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit
|
|
section</a>, data lines must consist of zero or more U+0020
|
|
SPACE and U+0009 CHARACTER TABULATION (tab) characters, a
|
|
<a href="urls.html#valid-url">valid URL</a> identifying a resource other than the
|
|
manifest itself, and then zero or more U+0020 SPACE and U+0009
|
|
CHARACTER TABULATION (tab) characters.</p>
|
|
|
|
<p>When the current section is the <a href="#concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback
|
|
section</a>, data lines must consist of zero or more U+0020
|
|
SPACE and U+0009 CHARACTER TABULATION (tab) characters, a
|
|
<a href="urls.html#valid-url">valid URL</a> identifying a resource other than the
|
|
manifest itself, one or more U+0020 SPACE and U+0009 CHARACTER
|
|
TABULATION (tab) characters, another <a href="urls.html#valid-url">valid URL</a>
|
|
identifying a resource other than the manifest itself, and then
|
|
zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab)
|
|
characters.</p>
|
|
|
|
<p>When the current section is the <a href="#concept-appcache-manifest-network" title="concept-appcache-manifest-network">online whitelist
|
|
section</a>, data lines must consist of zero or more U+0020
|
|
SPACE and U+0009 CHARACTER TABULATION (tab) characters, either a
|
|
single U+002A ASTERISK character (*) or a <a href="urls.html#valid-url">valid
|
|
URL</a> identifying a resource other than the manifest itself,
|
|
and then zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION
|
|
(tab) characters.</p>
|
|
|
|
|
|
</dd></dl><p>Manifests may contain sections more than once. Sections may be
|
|
empty.</p><p>If the manifest's <a href="urls.html#url-scheme" title="url-scheme"><scheme></a>
|
|
is <code title="">https:</code> or another scheme intended for
|
|
encrypted data transfer, then all URLs in <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit sections</a>
|
|
must have the <a href="origin-0.html#same-origin">same origin</a> as the manifest itself.</p><p>URLs that are to be fallback pages associated with <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespaces</a>, and
|
|
those namespaces themselves, must be given in <a href="#concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback sections</a>,
|
|
with the namespace being the first URL of the data line, and the
|
|
corresponding fallback page being the second URL. All the other
|
|
pages to be cached must be listed in <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit
|
|
sections</a>.</p><p><a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">Fallback
|
|
namespaces</a> and <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entries</a> must have
|
|
the <a href="origin-0.html#same-origin">same origin</a> as the manifest itself.</p><p>A <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
|
|
namespace</a> must not be listed more than once.</p><p>Namespaces that the user agent is to put into the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a>
|
|
must all be specified in <a href="#concept-appcache-manifest-network" title="concept-appcache-manifest-network">online whitelist
|
|
sections</a>. (This is needed for any URL that the page is
|
|
intending to use to communicate back to the server.) To specify that
|
|
all URLs are automatically whitelisted in this way, a U+002A
|
|
ASTERISK character (*) may be specified as one of the URLs. </p><p>Authors should not include namespaces in the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a> for
|
|
which another namespace in the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a> is
|
|
a <a href="infrastructure.html#prefix-match">prefix match</a>.</p><p>Relative URLs must be given relative to the manifest's own
|
|
URL. All URLs in the manifest must have the same <a href="urls.html#url-scheme" title="url-scheme"><scheme></a> as the manifest itself
|
|
(either explicitly or implicitly, through the use of relative
|
|
URLs).</p><p>URLs in manifests must not have fragment identifiers (i.e. the
|
|
U+0023 NUMBER SIGN character isn't allowed in URLs in
|
|
manifests).</p><p><a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">Fallback
|
|
namespaces</a> and namespaces in the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a> are
|
|
matched by <a href="infrastructure.html#prefix-match">prefix match</a>.</p><div class="impl">
|
|
|
|
<h5 id="parsing-cache-manifests"><span class="secno">5.6.3.3 </span>Parsing cache manifests</h5>
|
|
|
|
<p>When a user agent is to <dfn id="parse-a-manifest">parse a manifest</dfn>, it means
|
|
that the user agent must run the following steps:</p>
|
|
|
|
<ol><li><p>The user agent must decode the byte stream corresponding
|
|
with the manifest to be parsed <a href="infrastructure.html#decoded-as-utf-8-with-error-handling" title="decoded as UTF-8, with
|
|
error handling">as UTF-8, with error handling</a>. </p></li>
|
|
|
|
<li><p>Let <var title="">base URL</var> be the <a href="urls.html#absolute-url">absolute
|
|
URL</a> representing the manifest.</p></li>
|
|
|
|
<li><p>Let <var title="">explicit URLs</var> be an initially empty
|
|
list of <a href="urls.html#absolute-url" title="absolute URL">absolute URLs</a> for <a href="#concept-appcache-explicit" title="concept-appcache-explicit">explicit entries</a>.</p></li>
|
|
|
|
<li><p>Let <var title="">fallback URLs</var> be an initially empty
|
|
mapping of <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
|
|
namespaces</a> to <a href="urls.html#absolute-url" title="absolute URL">absolute
|
|
URLs</a> for <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback
|
|
entries</a>.</p></li>
|
|
|
|
<li><p>Let <var title="">online whitelist namespaces</var> be an
|
|
initially empty list of <a href="urls.html#absolute-url" title="absolute URL">absolute
|
|
URLs</a> for an <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online
|
|
whitelist</a>.</p></li>
|
|
|
|
<li><p>Let <var title="">online whitelist wildcard flag</var> be <i title="">blocking</i>. </p></li>
|
|
|
|
<li><p>Let <var title="">input</var> be the decoded text of the
|
|
manifest's byte stream.</p></li>
|
|
|
|
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the first
|
|
character.</p></li>
|
|
|
|
<li><p>If <var title="">position</var> is pointing at a U+FEFF BYTE
|
|
ORDER MARK (BOM) character, then advance <var title="">position</var> to the next character.</p></li>
|
|
|
|
<li><p>If the characters starting from <var title="">position</var>
|
|
are "CACHE", followed by a U+0020 SPACE character, followed by
|
|
"MANIFEST", then advance <var title="">position</var> to the next
|
|
character after those. Otherwise, this isn't a cache manifest;
|
|
abort this algorithm with a failure while checking for the magic
|
|
signature.</p></li>
|
|
|
|
<li><p>If the character at <var title="">position</var> is neither
|
|
a U+0020 SPACE character, a U+0009 CHARACTER TABULATION (tab)
|
|
character, U+000A LINE FEED (LF) character, nor a U+000D CARRIAGE
|
|
RETURN (CR) character, then this isn't a cache manifest; abort this
|
|
algorithm with a failure while checking for the magic
|
|
signature.</p></li>
|
|
|
|
<li><p>This is a cache manifest. The algorithm cannot fail beyond
|
|
this point (though bogus lines can get ignored).</p></li>
|
|
|
|
<li><p><a href="common-microsyntaxes.html#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are
|
|
<em>not</em> U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)
|
|
characters, and ignore those characters. (Extra text on the first
|
|
line, after the signature, is ignored.)</p></li>
|
|
|
|
<li><p>Let <var title="">mode</var> be "explicit".</p></li>
|
|
|
|
<li><p><i>Start of line</i>: If <var title="">position</var> is
|
|
past the end of <var title="">input</var>, then jump to the last
|
|
step. Otherwise, <a href="common-microsyntaxes.html#collect-a-sequence-of-characters">collect a sequence of characters</a> that
|
|
are U+000A LINE FEED (LF), U+000D CARRIAGE RETURN (CR), U+0020
|
|
SPACE, or U+0009 CHARACTER TABULATION (tab) characters.</p></li>
|
|
|
|
|
|
<li><p>Now, <a href="common-microsyntaxes.html#collect-a-sequence-of-characters">collect a sequence of characters</a> that are
|
|
<em>not</em> U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)
|
|
characters, and let the result be <var title="">line</var>.</p></li>
|
|
|
|
<li><p>Drop any trailing U+0020 SPACE and U+0009 CHARACTER
|
|
TABULATION (tab) characters at the end of <var title="">line</var>.</p></li>
|
|
|
|
<li><p>If <var title="">line</var> is the empty string, then jump
|
|
back to the step labeled "start of line".</p></li>
|
|
|
|
<li><p>If the first character in <var title="">line</var> is a
|
|
U+0023 NUMBER SIGN character (#), then jump back to the step
|
|
labeled "start of line".</p></li>
|
|
|
|
<li><p>If <var title="">line</var> equals "CACHE:" (the word
|
|
"CACHE" followed by a U+003A COLON character (:)), then set <var title="">mode</var> to "explicit" and jump back to the step
|
|
labeled "start of line".</p></li>
|
|
|
|
<li><p>If <var title="">line</var> equals "FALLBACK:" (the word
|
|
"FALLBACK" followed by a U+003A COLON character (:)), then set <var title="">mode</var> to "fallback" and jump back to the step
|
|
labeled "start of line".</p></li>
|
|
|
|
<li><p>If <var title="">line</var> equals "NETWORK:" (the word
|
|
"NETWORK" followed by a U+003A COLON character (:)), then set <var title="">mode</var> to "online whitelist" and jump back to the step
|
|
labeled "start of line".</p></li>
|
|
|
|
<li><p>If <var title="">line</var> ends with a U+003A COLON
|
|
character (:), then set <var title="">mode</var> to "unknown" and
|
|
jump back to the step labeled "start of line".</p></li>
|
|
|
|
<li><p>This is either a data line or it is syntactically
|
|
incorrect.</p></li>
|
|
|
|
<li><p>Let <var title="">position</var> be a pointer into <var title="">line</var>, initially pointing at the start of the
|
|
string.</p></li>
|
|
|
|
<li><p>Let <var title="">tokens</var> be a list of strings,
|
|
initially empty.</p></li>
|
|
|
|
<li>
|
|
|
|
<p>While <var title="">position</var> doesn't point past the end
|
|
of <var title="">line</var>:</p>
|
|
|
|
<ol><li><p>Let <var title="">current token</var> be an empty
|
|
string.</p></li>
|
|
|
|
<li><p>While <var title="">position</var> doesn't point past the
|
|
end of <var title="">line</var> and the character at <var title="">position</var> is neither a U+0020 SPACE nor a U+0009
|
|
CHARACTER TABULATION (tab) character, add the character at <var title="">position</var> to <var title="">current token</var> and
|
|
advance <var title="">position</var> to the next character in
|
|
<var title="">input</var>.</p></li>
|
|
|
|
<li><p>Add <var title="">current token</var> to the <var title="">tokens</var> list.</p></li>
|
|
|
|
<li><p>While <var title="">position</var> doesn't point past the
|
|
end of <var title="">line</var> and the character at <var title="">position</var> is either a U+0020 SPACE or a U+0009
|
|
CHARACTER TABULATION (tab) character, advance <var title="">position</var> to the next character in <var title="">input</var>.</p></li>
|
|
|
|
</ol></li>
|
|
|
|
<li>
|
|
|
|
<p>Process <var title="">tokens</var> as follows:</p>
|
|
|
|
<dl class="switch"><dt>If <var title="">mode</var> is "explicit"</dt>
|
|
|
|
<dd>
|
|
|
|
<p><a href="urls.html#resolve-a-url" title="resolve a url">Resolve</a> the first item in
|
|
<var title="">tokens</var>, relative to <var title="">base
|
|
URL</var>; ignore the rest.</p>
|
|
|
|
<p>If this fails, then jump back to the step labeled "start of
|
|
line".</p>
|
|
|
|
<p>If the resulting <a href="urls.html#absolute-url">absolute URL</a> has a different
|
|
<a href="urls.html#url-scheme" title="url-scheme"><scheme></a> component than
|
|
the manifest's URL (compared in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
|
|
case-insensitive</a> manner), then jump back to the step
|
|
labeled "start of line". If the manifest's <a href="urls.html#url-scheme" title="url-scheme"><scheme></a> is <code title="">https:</code> or another scheme intended for encrypted
|
|
data transfer, and the resulting <a href="urls.html#absolute-url">absolute URL</a> does
|
|
not have the <a href="origin-0.html#same-origin">same origin</a> as the manifest's URL,
|
|
then jump back to the step labeled "start of line".</p>
|
|
|
|
<p>Drop the <a href="urls.html#url-fragment" title="url-fragment"><fragment></a>
|
|
component of the resulting <a href="urls.html#absolute-url">absolute URL</a>, if it has
|
|
one.</p>
|
|
|
|
<p>Add the resulting <a href="urls.html#absolute-url">absolute URL</a> to the <var title="">explicit URLs</var>.</p>
|
|
|
|
</dd>
|
|
|
|
<dt>If <var title="">mode</var> is "fallback"</dt>
|
|
|
|
<dd>
|
|
|
|
<p>Let <var title="">part one</var> be the first token in <var title="">tokens</var>, and let <var title="">part two</var> be
|
|
the second token in <var title="">tokens</var>.</p>
|
|
|
|
<p><a href="urls.html#resolve-a-url" title="resolve a url">Resolve</a> <var title="">part
|
|
one</var> and <var title="">part two</var>, relative to <var title="">base URL</var>.</p>
|
|
|
|
<p>If either fails, then jump back to the step labeled "start of
|
|
line".</p>
|
|
|
|
<p>If the <a href="urls.html#absolute-url">absolute URL</a> corresponding to either <var title="">part one</var> or <var title="">part two</var> does not
|
|
have the <a href="origin-0.html#same-origin">same origin</a> as the manifest's URL, then
|
|
jump back to the step labeled "start of line".</p>
|
|
<p>Drop any <a href="urls.html#url-fragment" title="url-fragment"><fragment></a>
|
|
components of the resulting <a href="urls.html#absolute-url" title="absolute URL">absolute
|
|
URLs</a>.</p>
|
|
|
|
<p>If the <a href="urls.html#absolute-url">absolute URL</a> corresponding to <var title="">part one</var> is already in the <var title="">fallback
|
|
URLs</var> mapping as a <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>,
|
|
then jump back to the step labeled "start of line".</p>
|
|
|
|
<p>Otherwise, add the <a href="urls.html#absolute-url">absolute URL</a> corresponding to
|
|
<var title="">part one</var> to the <var title="">fallback
|
|
URLs</var> mapping as a <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>,
|
|
mapped to the <a href="urls.html#absolute-url">absolute URL</a> corresponding to <var title="">part two</var> as the <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entry</a>.</p>
|
|
|
|
</dd>
|
|
|
|
<dt>If <var title="">mode</var> is "online whitelist"</dt>
|
|
|
|
<dd>
|
|
|
|
<p>If the first item in <var title="">tokens</var> is a U+002A
|
|
ASTERISK character (*), then set <var title="">online whitelist
|
|
wildcard flag</var> to <i title="">open</i> and jump back to the
|
|
step labeled "start of line".</p>
|
|
|
|
<p>Otherwise, <a href="urls.html#resolve-a-url" title="resolve a url">resolve</a> the
|
|
first item in <var title="">tokens</var>, relative to <var title="">base URL</var>; ignore the rest.</p>
|
|
|
|
<p>If this fails, then jump back to the step labeled "start of
|
|
line".</p>
|
|
|
|
<p>If the resulting <a href="urls.html#absolute-url">absolute URL</a> has a different
|
|
<a href="urls.html#url-scheme" title="url-scheme"><scheme></a> component than
|
|
the manifest's URL (compared in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
|
|
case-insensitive</a> manner), then jump back to the step
|
|
labeled "start of line".</p>
|
|
|
|
<p>Drop the <a href="urls.html#url-fragment" title="url-fragment"><fragment></a>
|
|
component of the resulting <a href="urls.html#absolute-url">absolute URL</a>, if it has
|
|
one.</p>
|
|
|
|
<p>Add the resulting <a href="urls.html#absolute-url">absolute URL</a> to the <var title="">online whitelist namespaces</var>.</p>
|
|
|
|
</dd>
|
|
|
|
<dt>If <var title="">mode</var> is "unknown"</dt>
|
|
|
|
<dd>
|
|
|
|
<p>Do nothing. The line is ignored.</p>
|
|
|
|
</dd>
|
|
|
|
</dl></li>
|
|
|
|
<li><p>Jump back to the step labeled "start of line". (That step
|
|
jumps to the next, and last, step when the end of the file is
|
|
reached.)</p></li>
|
|
|
|
<li><p>Return the <var title="">explicit URLs</var> list, the <var title="">fallback URLs</var> mapping, the <var title="">online
|
|
whitelist namespaces</var>, and the <var title="">online whitelist
|
|
wildcard flag</var>.</p></li>
|
|
|
|
</ol><div class="note">
|
|
|
|
<p>The resource that declares the manifest (with the <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute) will always
|
|
get taken from the cache, whether it is listed in the cache or not,
|
|
even if it is listed in an <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
|
|
namespace</a>.</p>
|
|
|
|
<p>If a resource is listed in the <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit section</a>
|
|
or as a <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback
|
|
entry</a> in the <a href="#concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback section</a>,
|
|
the resource will always be taken from the cache, regardless of any
|
|
other matching entries in the <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespaces</a> or
|
|
<a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
|
|
namespaces</a>.</p>
|
|
|
|
<p>When a <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
|
|
namespace</a> and an <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
|
|
namespace</a> overlap, the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
|
|
namespace</a> has priority.</p>
|
|
|
|
<p>The <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
|
|
wildcard flag</a> is applied last, only for URLs that match
|
|
neither the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online
|
|
whitelist namespace</a> nor the <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a> and
|
|
that are not listed in the <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit
|
|
section</a>.</p>
|
|
|
|
</div>
|
|
|
|
|
|
<h4 id="downloading-or-updating-an-application-cache"><span class="secno">5.6.4 </span>Downloading or updating an application cache</h4>
|
|
|
|
<p>When the user agent is required (by other parts of this
|
|
specification) to start the <dfn id="application-cache-download-process">application cache download
|
|
process</dfn> for an <a href="urls.html#absolute-url">absolute URL</a> purported to identify
|
|
a <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a>, or for an
|
|
<a href="#application-cache-group">application cache group</a>, potentially given a particular
|
|
<a href="#cache-host">cache host</a>, and potentially given a <a href="#concept-appcache-master" title="concept-appcache-master">master</a> resource, the user
|
|
agent must run the steps below. These steps are always run
|
|
asynchronously, in parallel with the <a href="webappapis.html#event-loop">event loop</a> <a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>
|
|
|
|
<p>Some of these steps have requirements that only apply if the user
|
|
agent <dfn id="shows-caching-progress">shows caching progress</dfn>. Support for this is
|
|
optional. Caching progress UI could consist of a progress bar or
|
|
message panel in the user agent's interface, or an overlay, or
|
|
something else. Certain events fired during the <a href="#application-cache-download-process">application
|
|
cache download process</a> allow the script to override the display
|
|
of such an interface. The goal of this is to allow Web applications
|
|
to provide more seamless update mechanisms, hiding from the user the
|
|
mechanics of the application cache mechanism. User agents may
|
|
display user interfaces independent of this, but are encouraged to
|
|
not show prominent update progress notifications for applications
|
|
that cancel the relevant events.</p>
|
|
|
|
<p class="note">These events are delayed until after the <code title="event-load">load</code> event has fired.</p>
|
|
|
|
<p>The <a href="#application-cache-download-process">application cache download process</a> steps are as
|
|
follows:
|
|
|
|
</p><ol><li><p>Optionally, wait until the permission to start the
|
|
<a href="#application-cache-download-process">application cache download process</a> has been obtained
|
|
from the user and until the user agent is confident that the
|
|
network is available. This could include doing nothing until the
|
|
user explicitly opts-in to caching the site, or could involve
|
|
prompting the user for permission. The algorithm might never get
|
|
past this point. (This step is particularly intended to be used by
|
|
user agents running on severely space-constrained devices or in
|
|
highly privacy-sensitive environments).</p></li>
|
|
|
|
<li>
|
|
|
|
<p>Atomically, so as to avoid race conditions, perform the
|
|
following substeps:</p>
|
|
|
|
<ol><li>
|
|
|
|
<p>Pick the appropriate substeps:</p>
|
|
|
|
<dl class="switch"><dt>If these steps were invoked with an <a href="urls.html#absolute-url">absolute
|
|
URL</a> purported to identify a <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a></dt>
|
|
|
|
<dd>
|
|
|
|
<p>Let <var title="">manifest URL</var> be that <a href="urls.html#absolute-url">absolute
|
|
URL</a>.</p>
|
|
|
|
<p>If there is no <a href="#application-cache-group">application cache group</a>
|
|
identified by <var title="">manifest URL</var>, then create a
|
|
new <a href="#application-cache-group">application cache group</a> identified by <var title="">manifest URL</var>. Initially, it has no <a href="#application-cache" title="application cache">application caches</a>. One will
|
|
be created later in this algorithm.</p>
|
|
|
|
</dd>
|
|
|
|
|
|
<dt>If these steps were invoked with an <a href="#application-cache-group">application cache
|
|
group</a></dt>
|
|
|
|
<dd>
|
|
|
|
<p>Let <var title="">manifest URL</var> be the <a href="urls.html#absolute-url">absolute
|
|
URL</a> of the <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> used to
|
|
identify the <a href="#application-cache-group">application cache group</a> to be
|
|
updated.</p>
|
|
|
|
<p>If that <a href="#application-cache-group">application cache group</a> is <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>, then abort
|
|
this instance of the <a href="#application-cache-download-process">application cache download
|
|
process</a>. This can happen if another instance of this
|
|
algorithm found the manifest to be 404 or 410 while this
|
|
algorithm was waiting in the first step above.</p>
|
|
|
|
</dd>
|
|
|
|
</dl></li>
|
|
|
|
<li><p>Let <var title="">cache group</var> be the
|
|
<a href="#application-cache-group">application cache group</a> identified by <var title="">manifest URL</var>.</p></li>
|
|
|
|
<li><p>If these steps were invoked with a <a href="#concept-appcache-master" title="concept-appcache-master">master</a> resource, then add
|
|
the resource, along with the resource's <code><a href="infrastructure.html#document">Document</a></code>, to
|
|
<var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</a>.</p></li>
|
|
|
|
<li><p>If these steps were invoked with a <a href="#cache-host">cache
|
|
host</a>, and the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> is <i>checking</i> or
|
|
<i>downloading</i>, then <a href="#queue-a-post-load-task">queue a post-load task</a> to
|
|
<a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <code title="event-appcache-checking"><a href="#event-appcache-checking">checking</a></code> that is
|
|
cancelable at the <code><a href="#applicationcache">ApplicationCache</a></code> singleton of that
|
|
<a href="#cache-host">cache host</a>. The default action of this event must
|
|
be, if the user agent <a href="#shows-caching-progress">shows caching progress</a>, the
|
|
display of some sort of user interface indicating to the user
|
|
that the user agent is checking to see if it can download the
|
|
application.</p></li>
|
|
|
|
<li><p>If these steps were invoked with a <a href="#cache-host">cache
|
|
host</a>, and the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> is <i>downloading</i>, then also
|
|
<a href="#queue-a-post-load-task">queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
|
|
event</a> named <code title="event-appcache-downloading"><a href="#event-appcache-downloading">downloading</a></code> that is
|
|
cancelable at the <code><a href="#applicationcache">ApplicationCache</a></code> singleton of that
|
|
<a href="#cache-host">cache host</a>. The default action of this event must
|
|
be, if the user agent <a href="#shows-caching-progress">shows caching progress</a>, the
|
|
display of some sort of user interface indicating to the user the
|
|
application is being downloaded.</p></li>
|
|
|
|
<li><p>If the <a href="#concept-appcache-status" title="concept-appcache-status">status</a>
|
|
of the <var title="">cache group</var> is either <i>checking</i>
|
|
or <i>downloading</i>, then abort this instance of the
|
|
<a href="#application-cache-download-process">application cache download process</a>, as an update is
|
|
already in progress.</p></li>
|
|
|
|
<li><p>Set the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> to <i>checking</i>.</p>
|
|
|
|
</li><li><p>For each <a href="#cache-host">cache host</a> associated with an
|
|
<a href="#application-cache">application cache</a> in <var title="">cache
|
|
group</var>, <a href="#queue-a-post-load-task">queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a
|
|
simple event</a> that is cancelable named <code title="event-appcache-checking"><a href="#event-appcache-checking">checking</a></code> at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a>. The default action of these events must be, if the
|
|
user agent <a href="#shows-caching-progress">shows caching progress</a>, the display of
|
|
some sort of user interface indicating to the user that the user
|
|
agent is checking for the availability of updates.</p></li>
|
|
|
|
</ol><p class="note">The remainder of the steps run asynchronously.</p>
|
|
|
|
<p>If <var title="">cache group</var> already has an
|
|
<a href="#application-cache">application cache</a> in it, then this is an <dfn id="concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade attempt</dfn>. Otherwise,
|
|
this is a <dfn id="concept-appcache-cache" title="concept-appcache-cache">cache
|
|
attempt</dfn>.</p>
|
|
|
|
</li>
|
|
|
|
<li><p>If this is a <a href="#concept-appcache-cache" title="concept-appcache-cache">cache
|
|
attempt</a>, then this algorithm was invoked with a <a href="#cache-host">cache
|
|
host</a>; <a href="#queue-a-post-load-task">queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a
|
|
simple event</a> named <code title="event-appcache-checking"><a href="#event-appcache-checking">checking</a></code> that is cancelable
|
|
at the <code><a href="#applicationcache">ApplicationCache</a></code> singleton of that <a href="#cache-host">cache
|
|
host</a>. The default action of this event must be, if the user
|
|
agent <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort
|
|
of user interface indicating to the user that the user agent is
|
|
checking for the availability of updates.</p></li>
|
|
|
|
<li>
|
|
|
|
<p><i>Fetching the manifest</i>: <a href="fetching-resources.html#fetch">Fetch</a> the resource
|
|
from <var title="">manifest URL</var> with the <i>synchronous
|
|
flag</i> set, and let <var title="">manifest</var> be that
|
|
resource.</p>
|
|
<p>If the resource is labeled with the <a href="infrastructure.html#mime-type">MIME type</a>
|
|
<code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code>, parse <var title="">manifest</var> according to the <a href="#parse-a-manifest" title="parse a
|
|
manifest">rules for parsing manifests</a>, obtaining a list of
|
|
<a href="#concept-appcache-explicit" title="concept-appcache-explicit">explicit entries</a>,
|
|
<a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entries</a>
|
|
and the <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
|
|
namespaces</a> that map to them, entries for the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a>,
|
|
and a value for the <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
|
|
wildcard flag</a>.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>If <i>fetching the manifest</i> fails due to a 404 or 410
|
|
response <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or
|
|
equivalent</a>, then run these substeps:</p>
|
|
|
|
<ol><li><p>Mark <var title="">cache group</var> as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>. This <var title="">cache group</var> no longer exists for any purpose other
|
|
than the processing of <code><a href="infrastructure.html#document">Document</a></code> objects already
|
|
associated with an <a href="#application-cache">application cache</a> in the <var title="">cache group</var>.</p></li>
|
|
|
|
<li><p>Let <var title="">task list</var> be an empty list of
|
|
<a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>
|
|
|
|
</li><li><p>For each <a href="#cache-host">cache host</a> associated with an
|
|
<a href="#application-cache">application cache</a> in <var title="">cache
|
|
group</var>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to
|
|
<a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <code title="event-appcache-obsolete"><a href="#event-appcache-obsolete">obsolete</a></code> that is
|
|
cancelable at the <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the
|
|
<a href="#cache-host">cache host</a>, and append it to <var title="">task
|
|
list</var>. The default action of these events must be, if the
|
|
user agent <a href="#shows-caching-progress">shows caching progress</a>, the display of
|
|
some sort of user interface indicating to the user that the
|
|
application is no longer available for offline use.</p></li>
|
|
|
|
<li><p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</a>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a>
|
|
to <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> that is cancelable named
|
|
<code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> (not <code title="event-appcache-obsolete"><a href="#event-appcache-obsolete">obsolete</a></code>!) at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a> the <code><a href="infrastructure.html#document">Document</a></code> for this entry, if there
|
|
still is one, and append it to <var title="">task list</var>. The
|
|
default action of this event must be, if the user agent
|
|
<a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
|
|
user interface indicating to the user that the user agent failed
|
|
to save the application for offline use.</p></li>
|
|
|
|
<li><p>If <var title="">cache group</var> has an
|
|
<a href="#application-cache">application cache</a> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
|
|
<i>incomplete</i>, then discard that <a href="#application-cache">application
|
|
cache</a>.</p>
|
|
|
|
</li><li><p>If appropriate, remove any user interface indicating that
|
|
an update for this cache is in progress.</p></li>
|
|
|
|
<li><p>Let the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> be <i>idle</i>.</p></li>
|
|
|
|
<li><p>For each <a href="webappapis.html#concept-task" title="concept-task">task</a> in <var title="">task list</var>, <a href="#queue-a-post-load-task" title="queue a post-load
|
|
task">queue that task as a post-load task</a>.</p></li>
|
|
|
|
<li><p>Abort the <a href="#application-cache-download-process">application cache download
|
|
process</a>.</p></li>
|
|
|
|
</ol></li>
|
|
|
|
<li>
|
|
|
|
<p>Otherwise, if <i>fetching the manifest</i> fails in some other
|
|
way (e.g. the server returns another 4xx or 5xx response <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or equivalent</a>, or
|
|
there is a DNS error, or the connection times out, or the user
|
|
cancels the download, or the parser for manifests fails when
|
|
checking the magic signature), or if the server returned a
|
|
redirect, or if the resource is labeled with a <a href="infrastructure.html#mime-type">MIME
|
|
type</a> other than <code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code>, then run
|
|
the <a href="#cache-failure-steps">cache failure steps</a>.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>If this is an <a href="#concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade
|
|
attempt</a> and the newly downloaded <var title="">manifest</var> is byte-for-byte identical to the manifest
|
|
found in the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a>
|
|
<a href="#application-cache">application cache</a> in <var title="">cache group</var>,
|
|
or the server reported it as "304 Not Modified" <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or equivalent</a>, then
|
|
run these substeps:</p>
|
|
|
|
<ol><li><p>Let <var title="">cache</var> be the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> <a href="#application-cache">application
|
|
cache</a> in <var title="">cache group</var>.</p></li>
|
|
|
|
<li><p>Let <var title="">task list</var> be an empty list of
|
|
<a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>
|
|
|
|
</li><li>
|
|
|
|
<p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</a>, wait for the resource for this entry to have
|
|
either completely downloaded or failed.</p>
|
|
|
|
<p>If the download failed (e.g. the connection times out, or the
|
|
user cancels the download), then create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
|
|
event</a> that is cancelable named <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a> the <code><a href="infrastructure.html#document">Document</a></code> for this entry, if there
|
|
still is one, and append it to <var title="">task list</var>. The
|
|
default action of this event must be, if the user agent
|
|
<a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
|
|
user interface indicating to the user that the user agent failed
|
|
to save the application for offline use.</p>
|
|
|
|
<p>Otherwise, associate the <code><a href="infrastructure.html#document">Document</a></code> for this entry
|
|
with <var title="">cache</var>; store the resource for this
|
|
entry in <var title="">cache</var>, if it isn't already there,
|
|
and categorize its entry as a <a href="#concept-appcache-master" title="concept-appcache-master">master entry</a>. If the
|
|
resource's <a href="urls.html#url">URL</a> has a <a href="urls.html#url-fragment" title="url-fragment"><fragment></a> component, it must
|
|
be removed from the entry in <var title="">cache</var>
|
|
(application caches never include fragment identifiers).</p>
|
|
|
|
<p class="note">HTTP caching rules, such as <code title="">Cache-Control: no-store</code>, are ignored for the
|
|
purposes of the <a href="#application-cache-download-process">application cache download
|
|
process</a>.</p>
|
|
|
|
</li>
|
|
|
|
<li><p>For each <a href="#cache-host">cache host</a> associated with an
|
|
<a href="#application-cache">application cache</a> in <var title="">cache
|
|
group</var>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to
|
|
<a href="webappapis.html#fire-a-simple-event">fire a simple event</a> that is cancelable named <code title="event-appcache-noupdate"><a href="#event-appcache-noupdate">noupdate</a></code> at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a>, and append it to <var title="">task list</var>. The
|
|
default action of these events must be, if the user agent
|
|
<a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
|
|
user interface indicating to the user that the application is up
|
|
to date.</p></li>
|
|
|
|
<li><p>Empty <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</a>.</p></li>
|
|
|
|
<li><p>If appropriate, remove any user interface indicating that
|
|
an update for this cache is in progress.</p></li>
|
|
|
|
<li><p>Let the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> be <i>idle</i>.</p></li>
|
|
|
|
<li><p>For each <a href="webappapis.html#concept-task" title="concept-task">task</a> in <var title="">task list</var>, <a href="#queue-a-post-load-task" title="queue a post-load
|
|
task">queue that task as a post-load task</a>.</p></li>
|
|
|
|
<li><p>Abort the <a href="#application-cache-download-process">application cache download
|
|
process</a>.</p></li>
|
|
|
|
</ol></li>
|
|
|
|
<li><p>Let <var title="">new cache</var> be a newly created
|
|
<a href="#application-cache">application cache</a> in <var title="">cache
|
|
group</var>. Set its <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> to
|
|
<i>incomplete</i>.</p></li>
|
|
|
|
<li><p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</a>, associate the <code><a href="infrastructure.html#document">Document</a></code> for this entry
|
|
with <var title="">new cache</var>.</p></li>
|
|
|
|
<li><p>Set the <a href="#concept-appcache-status" title="concept-appcache-status">status</a>
|
|
of <var title="">cache group</var> to <i>downloading</i>.</p></li>
|
|
|
|
<li><p>For each <a href="#cache-host">cache host</a> associated with an
|
|
<a href="#application-cache">application cache</a> in <var title="">cache group</var>,
|
|
<a href="#queue-a-post-load-task">queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
|
|
event</a> that is cancelable named <code title="event-appcache-downloading"><a href="#event-appcache-downloading">downloading</a></code> at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a>. The default action of these events must be, if the
|
|
user agent <a href="#shows-caching-progress">shows caching progress</a>, the display of some
|
|
sort of user interface indicating to the user that a new version is
|
|
being downloaded.</p></li>
|
|
|
|
<li><p>Let <var title="">file list</var> be an empty list of
|
|
URLs with flags.</p></li>
|
|
|
|
<li><p>Add all the URLs in the list of <a href="#concept-appcache-explicit" title="concept-appcache-explicit">explicit entries</a> obtained
|
|
by parsing <var title="">manifest</var> to <var title="">file
|
|
list</var>, each flagged with "explicit entry".</p></li>
|
|
|
|
<li><p>Add all the URLs in the list of <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entries</a> obtained
|
|
by parsing <var title="">manifest</var> to <var title="">file
|
|
list</var>, each flagged with "fallback entry".</p></li>
|
|
|
|
<li><p>If this is an <a href="#concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade
|
|
attempt</a>, then add all the URLs of <a href="#concept-appcache-master" title="concept-appcache-master">master entries</a> in the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> <a href="#application-cache">application
|
|
cache</a> in <var title="">cache group</var> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
|
|
<i>complete</i> to <var title="">file list</var>, each flagged with
|
|
"master entry".</p></li>
|
|
|
|
<li><p>If any URL is in <var title="">file list</var> more than
|
|
once, then merge the entries into one entry for that URL, that
|
|
entry having all the flags that the original entries had.</p></li>
|
|
|
|
<li>
|
|
|
|
<p>For each URL in <var title="">file list</var>, run the
|
|
following steps. These steps may be run in parallel for two or
|
|
more of the URLs at a time.</p>
|
|
|
|
<ol><li>
|
|
|
|
<p>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.</p>
|
|
|
|
<p class="note">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.</p>
|
|
|
|
</li>
|
|
|
|
<li><p>For each <a href="#cache-host">cache host</a> associated with an
|
|
<a href="#application-cache">application cache</a> in <var title="">cache
|
|
group</var>, <a href="#queue-a-post-load-task">queue a post-load task</a> to fire an event
|
|
with the name <code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>, which does not
|
|
bubble, which is cancelable, and which uses the
|
|
<code>ProgressEvent</code> interface, at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a>. The <code title="dom-ProgressEvents-lengthComputable">lengthComputable</code>
|
|
attribute must be set to true, the <code title="dom-ProgressEvents-total">total</code> attribute must be
|
|
set to the number of files in <var title="">file list</var>, and
|
|
the <code title="dom-ProgressEvents-loaded">loaded</code>
|
|
attribute must be set to the number of number of files in <var title="">file list</var> that have been either downloaded or
|
|
skipped so far. The default action of these events must be, if
|
|
the user agent <a href="#shows-caching-progress">shows caching progress</a>, the display
|
|
of some sort of user interface indicating to the user that a file
|
|
is being downloaded in preparation for updating the
|
|
application. <a href="references.html#refsPROGRESS">[PROGRESS]</a></p></li>
|
|
|
|
<li>
|
|
|
|
<p><a href="fetching-resources.html#fetch">Fetch</a> the resource, from the <a href="origin-0.html#origin">origin</a>
|
|
of the <a href="urls.html#url">URL</a> <var title="">manifest URL</var>, with
|
|
the <i>synchronous flag</i> set and the <i>manual redirect
|
|
flag</i> set. If this is an <a href="#concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade attempt</a>, then
|
|
use the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a>
|
|
<a href="#application-cache">application cache</a> in <var title="">cache
|
|
group</var> as 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.</p>
|
|
|
|
<p class="note">If the resource in question is already being
|
|
downloaded for other reasons then the existing download process
|
|
can sometimes be used for the purposes of this step, as defined
|
|
by the <a href="fetching-resources.html#fetch" title="fetch">fetching</a> algorithm.</p>
|
|
|
|
<p class="example">An example of a resource that might already
|
|
be being downloaded is a large image on a Web page that is being
|
|
seen for the first time. The image would get downloaded to
|
|
satisfy the <code><a href="embedded-content-1.html#the-img-element">img</a></code> element on the page, as well as
|
|
being listed in the cache manifest. According to the rules for
|
|
<a href="fetching-resources.html#fetch" title="fetch">fetching</a> that image only need be
|
|
downloaded once, and it can be used both for the cache and for
|
|
the rendered Web page.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>If the previous step fails (e.g. the server returns a 4xx or
|
|
5xx response <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or
|
|
equivalent</a>, or there is a DNS error, or the connection
|
|
times out, or the user cancels the download), or if the server
|
|
returned a redirect, then run the first appropriate step from
|
|
the following list:</p>
|
|
|
|
<dl class="switch"><dt>If the URL being processed was flagged as an "explicit
|
|
entry" or a "fallback entry"</dt>
|
|
|
|
<dd>
|
|
|
|
<p>Run the <a href="#cache-failure-steps">cache failure steps</a>.</p>
|
|
|
|
<p class="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.</p>
|
|
|
|
</dd>
|
|
|
|
<dt>If the error was a 404 or 410 HTTP response <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or equivalent</a></dt>
|
|
|
|
<dd>
|
|
|
|
<p>Skip this resource. It is dropped from the cache.</p>
|
|
|
|
</dd>
|
|
|
|
<dt>Otherwise</dt>
|
|
|
|
<dd>
|
|
|
|
<p>Copy the resource and its metadata from the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> <a href="#application-cache">application
|
|
cache</a> in <var title="">cache group</var> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a>
|
|
is <i>complete</i>, and act as if that was the fetched
|
|
resource, ignoring the resource obtained from the network.</p>
|
|
|
|
</dd>
|
|
|
|
</dl><p>User agents may warn the user of these errors as an aid to
|
|
development.</p>
|
|
|
|
<p class="note">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.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>Otherwise, the fetching succeeded. Store the resource in
|
|
the <var title="">new cache</var>.</p>
|
|
|
|
<p>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 the <a href="#cache-failure-steps">cache
|
|
failure steps</a>.</p>
|
|
|
|
</li>
|
|
|
|
<li><p>If the URL being processed was flagged as an "explicit
|
|
entry" in <var title="">file list</var>, then categorize the
|
|
entry as an <a href="#concept-appcache-explicit" title="concept-appcache-explicit">explicit
|
|
entry</a>.</p></li>
|
|
|
|
<li><p>If the URL being processed was flagged as a "fallback
|
|
entry" in <var title="">file list</var>, then categorize the
|
|
entry as a <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback
|
|
entry</a>.</p></li>
|
|
|
|
<li><p>If the URL being processed was flagged as an "master
|
|
entry" in <var title="">file list</var>, then categorize the
|
|
entry as a <a href="#concept-appcache-master" title="concept-appcache-master">master
|
|
entry</a>.</p></li>
|
|
|
|
<li><p>As an optimization, if the resource is an HTML or XML file
|
|
whose root element is an <code><a href="semantics.html#the-html-element">html</a></code> element with a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute whose value
|
|
doesn't match the manifest URL of the application cache being
|
|
processed, then the user agent should mark the entry as being
|
|
<a href="#concept-appcache-foreign" title="concept-appcache-foreign">foreign</a>.</p>
|
|
|
|
</li></ol></li>
|
|
|
|
<li><p>For each <a href="#cache-host">cache host</a> associated with an
|
|
<a href="#application-cache">application cache</a> in <var title="">cache group</var>,
|
|
<a href="#queue-a-post-load-task">queue a post-load task</a> to fire an event with the name
|
|
<code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>, which does
|
|
not bubble, which is cancelable, and which uses the
|
|
<code>ProgressEvent</code> interface, at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a>. The <code title="dom-ProgressEvents-lengthComputable">lengthComputable</code>
|
|
attribute must be set to true, the <code title="dom-ProgressEvents-total">total</code> and the <code title="dom-ProgressEvents-loaded">loaded</code> attributes must be
|
|
set to the number of number of files in <var title="">file
|
|
list</var>. The default action of these events must be, if the user
|
|
agent <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort
|
|
of user interface indicating to the user that all the files have
|
|
been downloaded. <a href="references.html#refsPROGRESS">[PROGRESS]</a></p></li>
|
|
|
|
<li><p>Store the list of <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespaces</a>,
|
|
and the URLs of the <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entries</a> that they
|
|
map to, in <var title="">new cache</var>.</p></li>
|
|
|
|
<li><p>Store the URLs that form the new <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a> in
|
|
<var title="">new cache</var>.</p></li>
|
|
|
|
<li><p>Store the value of the new <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
|
|
wildcard flag</a> in <var title="">new cache</var>.</p></li>
|
|
|
|
<li>
|
|
|
|
<p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</a>, wait for the resource for this entry to have
|
|
either completely downloaded or failed.</p>
|
|
|
|
<p>If the download failed (e.g. the connection times out, or the
|
|
user cancels the download), then run these substeps:</p>
|
|
|
|
<ol><li><p>Unassociate the <code><a href="infrastructure.html#document">Document</a></code> for this entry from
|
|
<var title="">new cache</var>.</p></li>
|
|
|
|
<li><p><a href="#queue-a-post-load-task">Queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
|
|
event</a> that is cancelable named <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the
|
|
<code><a href="infrastructure.html#document">Document</a></code> for this entry, if there still is one. The
|
|
default action of this event must be, if the user agent
|
|
<a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
|
|
user interface indicating to the user that the user agent failed
|
|
to save the application for offline use.</p>
|
|
|
|
</li><li>
|
|
|
|
<p>If this is a <a href="#concept-appcache-cache" title="concept-appcache-cache">cache
|
|
attempt</a> and this entry is the last entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</a>, then run these further substeps:</p>
|
|
|
|
<ol><li><p>Discard <var title="">cache group</var> and its only
|
|
<a href="#application-cache">application cache</a>, <var title="">new
|
|
cache</var>.</p>
|
|
|
|
</li><li><p>If appropriate, remove any user interface indicating
|
|
that an update for this cache is in progress.</p></li>
|
|
|
|
<li><p>Abort the <a href="#application-cache-download-process">application cache download
|
|
process</a>.</p></li>
|
|
|
|
</ol></li>
|
|
|
|
<li><p>Otherwise, remove this entry from <var title="">cache
|
|
group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list
|
|
of pending master entries</a>.</p></li>
|
|
|
|
</ol><p>Otherwise, store the resource for this entry in <var title="">new cache</var>, if it isn't already there, and
|
|
categorize its entry as a <a href="#concept-appcache-master" title="concept-appcache-master">master entry</a>.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p><a href="fetching-resources.html#fetch">Fetch</a> the resource from <var title="">manifest
|
|
URL</var> again, with the <i>synchronous flag</i> set, and let
|
|
<var title="">second manifest</var> be that resource.</p>
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>If the previous step failed for any reason, or if the fetching
|
|
attempt involved a redirect, or if <var title="">second
|
|
manifest</var> and <var title="">manifest</var> are not
|
|
byte-for-byte identical, then schedule a rerun of the entire
|
|
algorithm with the same parameters after a short delay, and run
|
|
the <a href="#cache-failure-steps">cache failure steps</a>.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>Otherwise, store <var title="">manifest</var> in <var title="">new cache</var>, if it's not there already, and
|
|
categorize its entry as <a href="#concept-appcache-manifest" title="concept-appcache-manifest">the manifest</a>.</p>
|
|
|
|
</li>
|
|
|
|
<li><p>Set the <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> of
|
|
<var title="">new cache</var> to <i>complete</i>.</p></li>
|
|
|
|
<li><p>Let <var title="">task list</var> be an empty list of <a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>
|
|
|
|
</li><li>
|
|
|
|
<p>If this is a <a href="#concept-appcache-cache" title="concept-appcache-cache">cache
|
|
attempt</a>, then for each <a href="#cache-host">cache host</a> associated
|
|
with an <a href="#application-cache">application cache</a> in <var title="">cache
|
|
group</var>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to
|
|
<a href="webappapis.html#fire-a-simple-event">fire a simple event</a> that is cancelable named <code title="event-appcache-cached"><a href="#event-appcache-cached">cached</a></code> at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a>, and append it to <var title="">task list</var>. The
|
|
default action of these events must be, if the user agent
|
|
<a href="#shows-caching-progress">shows caching progress</a>, 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.</p>
|
|
|
|
<p>Otherwise, it is an <a href="#concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade attempt</a>. For each
|
|
<a href="#cache-host">cache host</a> associated with an <a href="#application-cache">application
|
|
cache</a> in <var title="">cache group</var>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
|
|
event</a> that is cancelable named <code title="event-appcache-updateready"><a href="#event-appcache-updateready">updateready</a></code> at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a>, and append it to <var title="">task list</var>. The
|
|
default action of these events must be, if the user agent
|
|
<a href="#shows-caching-progress">shows caching progress</a>, 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.</p>
|
|
|
|
</li>
|
|
|
|
<li><p>If appropriate, remove any user interface indicating that
|
|
an update for this cache is in progress.</p></li>
|
|
|
|
<li><p>Set the <a href="#concept-appcache-status" title="concept-appcache-status">update
|
|
status</a> of <var title="">cache group</var> to
|
|
<i>idle</i>.</p></li>
|
|
|
|
<li><p>For each <a href="webappapis.html#concept-task" title="concept-task">task</a> in <var title="">task list</var>, <a href="#queue-a-post-load-task" title="queue a post-load
|
|
task">queue that task as a post-load task</a>.</p></li>
|
|
|
|
</ol><p>The <dfn id="cache-failure-steps">cache failure steps</dfn> are as follows:</p>
|
|
|
|
<ol><li><p>Let <var title="">task list</var> be an empty list of <a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>
|
|
|
|
</li><li>
|
|
|
|
<p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</a>, run the following further substeps. These steps
|
|
may be run in parallel for two or more entries at a time.</p>
|
|
|
|
<ol><li><p>Wait for the resource for this entry to have either
|
|
completely downloaded or failed.</p>
|
|
|
|
</li><li><p>Unassociate the <code><a href="infrastructure.html#document">Document</a></code> for this entry from
|
|
its <a href="#application-cache">application cache</a>, if it has one.</p></li>
|
|
|
|
<li><p>Create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to
|
|
<a href="webappapis.html#fire-a-simple-event">fire a simple event</a> that is cancelable named <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the
|
|
<code><a href="infrastructure.html#document">Document</a></code> for this entry, if there still is one, and
|
|
append it to <var title="">task list</var>. The default action of
|
|
these events must be, if the user agent <a href="#shows-caching-progress">shows caching
|
|
progress</a>, the display of some sort of user interface
|
|
indicating to the user that the user agent failed to save the
|
|
application for offline use.</p>
|
|
|
|
</li></ol></li>
|
|
|
|
<li><p>For each <a href="#cache-host">cache host</a> still associated with an
|
|
<a href="#application-cache">application cache</a> in <var title="">cache group</var>,
|
|
create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to <a href="webappapis.html#fire-a-simple-event">fire a
|
|
simple event</a> that is cancelable named <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> at the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
|
|
host</a>, and append it to <var title="">task list</var>. The
|
|
default action of these events must be, if the user agent
|
|
<a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
|
|
user interface indicating to the user that the user agent failed to
|
|
save the application for offline use.</p></li>
|
|
|
|
<li><p>Empty <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
|
|
entries</a>.</p></li>
|
|
|
|
<li><p>If <var title="">cache group</var> has an <a href="#application-cache">application
|
|
cache</a> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
|
|
<i>incomplete</i>, then discard that <a href="#application-cache">application
|
|
cache</a>.</p>
|
|
|
|
</li><li><p>If appropriate, remove any user interface indicating that an
|
|
update for this cache is in progress.</p></li>
|
|
|
|
<li><p>Let the <a href="#concept-appcache-status" title="concept-appcache-status">status</a>
|
|
of <var title="">cache group</var> be <i>idle</i>.</p></li>
|
|
|
|
<li><p>If this was a <a href="#concept-appcache-cache" title="concept-appcache-cache">cache
|
|
attempt</a>, discard <var title="">cache group</var>
|
|
altogether.</p>
|
|
|
|
</li><li><p>For each <a href="webappapis.html#concept-task" title="concept-task">task</a> in <var title="">task list</var>, <a href="#queue-a-post-load-task" title="queue a post-load
|
|
task">queue that task as a post-load task</a>.</p></li>
|
|
|
|
<li><p>Abort the <a href="#application-cache-download-process">application cache download
|
|
process</a>.</p></li>
|
|
|
|
</ol><p>Attempts to <a href="fetching-resources.html#fetch">fetch</a> resources as part of the
|
|
<a href="#application-cache-download-process">application cache download process</a> may be done with
|
|
cache-defeating semantics, to avoid problems with stale or
|
|
inconsistent intermediary caches.</p>
|
|
|
|
<hr><p>User agents may invoke the <a href="#application-cache-download-process">application cache download
|
|
process</a>, in the background, for any <a href="#application-cache">application
|
|
cache</a>, at any time (with no <a href="#cache-host">cache host</a>). This
|
|
allows user agents to keep caches primed and to update caches even
|
|
before the user visits a site.</p>
|
|
|
|
<hr><p>Each <code><a href="infrastructure.html#document">Document</a></code> has a list of <dfn id="pending-application-cache-download-process-tasks">pending application
|
|
cache download process tasks</dfn> that is used to delay events
|
|
fired by the algorithm above until the document's <code title="event-load">load</code> event has fired. When the
|
|
<code><a href="infrastructure.html#document">Document</a></code> is created, the list must be empty.</p>
|
|
|
|
<p>When the steps above say to <dfn id="queue-a-post-load-task">queue a post-load task</dfn>
|
|
<var title="">task</var>, where <var title="">task</var> is a <a href="webappapis.html#concept-task" title="concept-task">task</a> that dispatches an event on a
|
|
target <code><a href="#applicationcache">ApplicationCache</a></code> object <var title="">target</var>, the user agent must run the appropriate steps
|
|
from the following list:</p>
|
|
|
|
<dl><dt>If <var title="">target</var>'s <code><a href="infrastructure.html#document">Document</a></code> is
|
|
<a href="the-end.html#ready-for-post-load-tasks">ready for post-load tasks</a></dt>
|
|
|
|
<dd><p><a href="webappapis.html#queue-a-task" title="queue a task">Queue</a> the task <var title="">task</var>.</p></dd>
|
|
|
|
<dt>Otherwise</dt>
|
|
|
|
<dd><p>Add <var title="">task</var> to <var title="">target</var>'s
|
|
<code><a href="infrastructure.html#document">Document</a></code>'s list of <a href="#pending-application-cache-download-process-tasks">pending application cache
|
|
download process tasks</a>.</p></dd>
|
|
|
|
</dl><p>The <a href="webappapis.html#task-source">task source</a> for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the <a href="webappapis.html#networking-task-source">networking task
|
|
source</a>.</p>
|
|
|
|
|
|
|
|
|
|
<h4 id="the-application-cache-selection-algorithm"><span class="secno">5.6.5 </span>The application cache selection algorithm</h4>
|
|
|
|
<p>When the <dfn id="concept-appcache-init" title="concept-appcache-init">application cache
|
|
selection algorithm</dfn> algorithm is invoked with a
|
|
<code><a href="infrastructure.html#document">Document</a></code> <var title="">document</var> and optionally a
|
|
manifest <a href="urls.html#url">URL</a> <var title="">manifest URL</var>, the user
|
|
agent must run the first applicable set of steps from the following
|
|
list:</p>
|
|
|
|
<dl class="switch"><dt>If there is a <var title="">manifest URL</var>, and <var title="">document</var> was loaded from an <a href="#application-cache">application
|
|
cache</a>, and the URL of the <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> of that cache's
|
|
<a href="#application-cache-group">application cache group</a> is <em>not</em> the same as
|
|
<var title="">manifest URL</var></dt>
|
|
|
|
<dd>
|
|
|
|
<p>Mark the entry for the resource from which <var title="">document</var> was taken in the <a href="#application-cache">application
|
|
cache</a> from which it was loaded as <a href="#concept-appcache-foreign" title="concept-appcache-foreign">foreign</a>.</p>
|
|
|
|
<p>Restart the current navigation from the top of the <a href="history.html#navigate" title="navigate">navigation algorithm</a>, undoing any changes
|
|
that were made as part of the initial load (changes can be avoided
|
|
by ensuring that the step to <a href="history.html#update-the-session-history-with-the-new-page">update the session history with
|
|
the new page</a> is only ever completed <em>after</em> this
|
|
<a href="#concept-appcache-init" title="concept-appcache-init">application cache selection
|
|
algorithm</a> is run, though this is not required).</p>
|
|
|
|
<p class="note">The navigation will not result in the same
|
|
resource being loaded, because "foreign" entries are never picked
|
|
during navigation.</p>
|
|
|
|
<p>User agents may notify the user of the inconsistency between
|
|
the cache manifest and the document's own metadata, to aid in
|
|
application development.</p>
|
|
|
|
</dd>
|
|
|
|
|
|
<dt>If <var title="">document</var> was loaded from an
|
|
<a href="#application-cache">application cache</a>, and that <a href="#application-cache">application
|
|
cache</a> still exists (it is not now <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>)</dt>
|
|
|
|
<dd>
|
|
|
|
<p>Associate <var title="">document</var> with the
|
|
<a href="#application-cache">application cache</a> from which it was loaded. Invoke,
|
|
in the background, the <a href="#application-cache-download-process">application cache download
|
|
process</a> for that <a href="#application-cache">application cache</a>'s
|
|
<a href="#application-cache-group">application cache group</a>, with <var title="">document</var> as the <a href="#cache-host">cache host</a>.</p>
|
|
|
|
</dd>
|
|
|
|
|
|
<dt>If <var title="">document</var> was loaded using
|
|
HTTP GET <a href="fetching-resources.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
|
|
equivalent</a>, and, there is a <var title="">manifest
|
|
URL</var>, and <var title="">manifest URL</var> has the <a href="origin-0.html#same-origin">same
|
|
origin</a> as <var title="">document</var></dt>
|
|
|
|
<dd>
|
|
|
|
<p>Invoke, in the background, the <a href="#application-cache-download-process">application cache download
|
|
process</a> for <var title="">manifest URL</var>, with <var title="">document</var> as the <a href="#cache-host">cache host</a> and with
|
|
the resource from which <var title="">document</var> was parsed as
|
|
the <a href="#concept-appcache-master" title="concept-appcache-master">master</a>
|
|
resource.</p>
|
|
|
|
</dd>
|
|
|
|
|
|
<dt>Otherwise</dt>
|
|
<dd>
|
|
|
|
<p>The <code><a href="infrastructure.html#document">Document</a></code> is not associated with any
|
|
<a href="#application-cache">application cache</a>.</p>
|
|
|
|
<p>If there was a <var title="">manifest URL</var>, the user agent
|
|
may report to the user that it was ignored, to aid in application
|
|
development.</p>
|
|
|
|
</dd>
|
|
|
|
</dl><h4 id="changesToNetworkingModel"><span class="secno">5.6.6 </span>Changes to the networking model</h4>
|
|
|
|
<p>When a <a href="#cache-host">cache host</a> is associated with an
|
|
<a href="#application-cache">application cache</a> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
|
|
<i>complete</i>, any and all loads for resources related to that
|
|
<a href="#cache-host">cache host</a> other than those for <a href="browsers.html#child-browsing-context" title="child
|
|
browsing context">child browsing contexts</a> must go through the
|
|
following steps instead of immediately invoking the mechanisms
|
|
appropriate to that resource's scheme:</p>
|
|
|
|
<ol><li><p>If the resource is not to be fetched using the HTTP GET
|
|
mechanism <a href="fetching-resources.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
|
|
equivalent</a>, or if its <a href="urls.html#url">URL</a> has a different <a href="urls.html#url-scheme" title="url-scheme"><scheme></a> component than the
|
|
<a href="#application-cache">application cache</a>'s <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a>, then
|
|
<a href="fetching-resources.html#fetch">fetch</a> the resource normally and abort these
|
|
steps.</p></li>
|
|
|
|
<li><p>If the resource's URL is <a href="#concept-appcache-master" title="concept-appcache-master">a master entry</a>, <a href="#concept-appcache-manifest" title="concept-appcache-manifest">the manifest</a>, <a href="#concept-appcache-explicit" title="concept-appcache-explicit">an explicit entry</a>, or
|
|
<a href="#concept-appcache-fallback" title="concept-appcache-fallback">a fallback entry</a> in
|
|
the <a href="#application-cache">application cache</a>, then get the resource from the
|
|
cache (instead of fetching it), and abort these steps.</p></li>
|
|
|
|
<li><p>If there is an entry in the <a href="#application-cache">application cache</a>'s
|
|
<a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online
|
|
whitelist</a> that has the <a href="origin-0.html#same-origin">same origin</a> as the
|
|
resource's URL and that is a <a href="infrastructure.html#prefix-match">prefix match</a> for the
|
|
resource's URL, then <a href="fetching-resources.html#fetch">fetch</a> the resource normally and
|
|
abort these steps.</p></li>
|
|
|
|
<li>
|
|
|
|
<p>If the resource's URL has the <a href="origin-0.html#same-origin">same origin</a> as the
|
|
manifest's URL, and there is a <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>
|
|
<var title="">f</var> in the <a href="#application-cache">application cache</a> that
|
|
is a <a href="infrastructure.html#prefix-match">prefix match</a> for the resource's URL, then:</p>
|
|
|
|
<p><a href="fetching-resources.html#fetch">Fetch</a> the resource normally. If this results in a
|
|
redirect to a resource with another <a href="origin-0.html#origin">origin</a>
|
|
(indicative of a captive portal), or a 4xx or 5xx status code
|
|
<a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or equivalent</a>,
|
|
or if there were network errors (but not if the user canceled the
|
|
download), then instead get, from the cache, the resource of the
|
|
<a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entry</a>
|
|
corresponding to the <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>
|
|
<var title="">f</var>. Abort these steps.</p>
|
|
|
|
</li>
|
|
|
|
<li><p>If the <a href="#application-cache">application cache</a>'s <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
|
|
wildcard flag</a> is <i title="">open</i>, then
|
|
<a href="fetching-resources.html#fetch">fetch</a> the resource normally and abort these
|
|
steps.</p></li>
|
|
|
|
<li><p>Fail the resource load as if there had been a generic
|
|
network error.</p></li>
|
|
|
|
</ol><p class="note">The above algorithm ensures that so long as the
|
|
<a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online
|
|
whitelist wildcard flag</a> is <i title="">blocking</i>,
|
|
resources that are not present in the <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> will always fail
|
|
to load (at least, after the <a href="#application-cache">application cache</a> has been
|
|
primed the first time), making the testing of offline applications
|
|
simpler.</p>
|
|
|
|
</div><div class="impl">
|
|
|
|
<h4 id="expiring-application-caches"><span class="secno">5.6.7 </span>Expiring application caches</h4>
|
|
|
|
<p>As a general rule, user agents should not expire application
|
|
caches, except on request from the user, or after having been left
|
|
unused for an extended period of time.</p>
|
|
|
|
<p>Application caches and cookies have similar implications with
|
|
respect to privacy (e.g. if the site can identify the user when
|
|
providing the cache, it can store data in the cache that can be used
|
|
for cookie resurrection). Implementors are therefore encouraged to
|
|
expose application caches in a manner related to HTTP cookies,
|
|
allowing caches to be expunged together with cookies and other
|
|
origin-specific data.</p>
|
|
|
|
<p class="example">For example, a user agent could have a "delete
|
|
site-specific data" feature that clears all cookies, application
|
|
caches, local storage, databases, etc, from an origin all at
|
|
once.</p>
|
|
|
|
</div><div class="impl">
|
|
|
|
<h4 id="disk-space"><span class="secno">5.6.8 </span>Disk space</h4>
|
|
|
|
<p>User agents should consider applying constraints on disk usage of
|
|
<a href="#application-cache" title="application cache">application caches</a>, and care
|
|
should be taken to ensure that the restrictions cannot be easily
|
|
worked around using subdomains.</p>
|
|
|
|
<p>User agents should allow users to see how much space each domain
|
|
is using, and may offer the user the ability to delete specific
|
|
<a href="#application-cache" title="application cache">application caches</a>.</p>
|
|
|
|
<p class="note">How quotas are presented to the user is not defined
|
|
by this specification. User agents are encouraged to provide
|
|
features such as allowing a user to indicate that certain sites are
|
|
trusted to use more than the default quota, e.g. by asynchronously
|
|
presenting a user interface while a cache is being updated, or by
|
|
having an explicit whitelist in the user agent's configuration
|
|
interface.</p>
|
|
|
|
</div><h4 id="application-cache-api"><span class="secno">5.6.9 </span>Application cache API</h4><pre class="idl">interface <dfn id="applicationcache">ApplicationCache</dfn> {
|
|
|
|
// <a href="#concept-appcache-status" title="concept-appcache-status">update status</a>
|
|
const unsigned short <a href="#dom-appcache-uncached" title="dom-appcache-UNCACHED">UNCACHED</a> = 0;
|
|
const unsigned short <a href="#dom-appcache-idle" title="dom-appcache-IDLE">IDLE</a> = 1;
|
|
const unsigned short <a href="#dom-appcache-checking" title="dom-appcache-CHECKING">CHECKING</a> = 2;
|
|
const unsigned short <a href="#dom-appcache-downloading" title="dom-appcache-DOWNLOADING">DOWNLOADING</a> = 3;
|
|
const unsigned short <a href="#dom-appcache-updateready" title="dom-appcache-UPDATEREADY">UPDATEREADY</a> = 4;
|
|
const unsigned short <a href="#dom-appcache-obsolete" title="dom-appcache-OBSOLETE">OBSOLETE</a> = 5;
|
|
readonly attribute unsigned short <a href="#dom-appcache-status" title="dom-appcache-status">status</a>;
|
|
|
|
// updates
|
|
void <a href="#dom-appcache-update" title="dom-appcache-update">update</a>();
|
|
void <a href="#dom-appcache-swapcache" title="dom-appcache-swapCache">swapCache</a>();
|
|
|
|
// events
|
|
attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onchecking" title="handler-appcache-onchecking">onchecking</a>;
|
|
attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onerror" title="handler-appcache-onerror">onerror</a>;
|
|
attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onnoupdate" title="handler-appcache-onnoupdate">onnoupdate</a>;
|
|
attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-ondownloading" title="handler-appcache-ondownloading">ondownloading</a>;
|
|
attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onprogress" title="handler-appcache-onprogress">onprogress</a>;
|
|
attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onupdateready" title="handler-appcache-onupdateready">onupdateready</a>;
|
|
attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-oncached" title="handler-appcache-oncached">oncached</a>;
|
|
attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onobsolete" title="handler-appcache-onobsolete">onobsolete</a>;
|
|
};
|
|
<a href="#applicationcache">ApplicationCache</a> implements <a href="infrastructure.html#eventtarget">EventTarget</a>;</pre><dl class="domintro"><dt><var title="">cache</var> = <var title="">window</var> . <code title="dom-applicationCache"><a href="#dom-applicationcache">applicationCache</a></code></dt>
|
|
<dd>
|
|
|
|
<p>(In a window.) Returns the <code><a href="#applicationcache">ApplicationCache</a></code> object that applies to the <a href="browsers.html#active-document">active document</a> of that <code><a href="browsers.html#window">Window</a></code>.</p>
|
|
|
|
</dd>
|
|
|
|
<dt><var title="">cache</var> = <var title="">self</var> . <code title="dom-applicationCache"><a href="#dom-applicationcache">applicationCache</a></code></dt>
|
|
<dd>
|
|
|
|
<p>(In a shared worker.) Returns the <code><a href="#applicationcache">ApplicationCache</a></code> object that applies to the current shared worker.
|
|
|
|
<a href="references.html#refsWEBWORKERS">[WEBWORKERS]</a>
|
|
|
|
</p>
|
|
|
|
</dd>
|
|
|
|
<dt><var title="">cache</var> . <code title="dom-appcache-status"><a href="#dom-appcache-status">status</a></code></dt>
|
|
<dd>
|
|
|
|
<p>Returns the current status of the application cache, as given by the constants defined below.</p>
|
|
|
|
</dd>
|
|
|
|
<dt><var title="">cache</var> . <code title="dom-appcache-update"><a href="#dom-appcache-update">update</a></code>()</dt>
|
|
<dd>
|
|
|
|
<p>Invokes the <a href="#application-cache-download-process">application cache download process</a>.</p>
|
|
|
|
<p>Throws an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception if there is no application cache to update.</p>
|
|
|
|
</dd>
|
|
|
|
<dt><var title="">cache</var> . <code title="dom-appcache-swapCache"><a href="#dom-appcache-swapcache">swapCache</a></code>()</dt>
|
|
<dd>
|
|
|
|
<p>Switches to the most recent application cache, if there is a
|
|
newer one. If there isn't, throws an
|
|
<code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
|
|
|
|
<p>This does not cause previously-loaded resources to be reloaded;
|
|
for example, images do not suddenly get reloaded and style sheets
|
|
and scripts do not get reparsed or reevaluated. The only change is
|
|
that subsequent requests for cached resources will obtain the
|
|
newer copies.</p>
|
|
|
|
</dd>
|
|
|
|
</dl><div class="impl">
|
|
|
|
<p>There is a one-to-one mapping from <a href="#cache-host" title="cache host">cache
|
|
hosts</a> to <code><a href="#applicationcache">ApplicationCache</a></code> objects. The <dfn id="dom-applicationcache" title="dom-applicationCache"><code>applicationCache</code></dfn>
|
|
attribute on <code><a href="browsers.html#window">Window</a></code> objects must return the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> object associated with the
|
|
<code><a href="browsers.html#window">Window</a></code> object's <a href="browsers.html#active-document">active document</a>. The <dfn id="dom-sharedworkerglobalscope-applicationcache" title="dom-SharedWorkerGlobalScope-applicationCache"><code>applicationCache</code></dfn>
|
|
attribute on <code>SharedWorkerGlobalScope</code> objects must
|
|
return the <code><a href="#applicationcache">ApplicationCache</a></code> object associated with the
|
|
worker.
|
|
|
|
<a href="references.html#refsWEBWORKERS">[WEBWORKERS]</a>
|
|
|
|
</p>
|
|
|
|
<p class="note">A <code><a href="browsers.html#window">Window</a></code> or
|
|
<code>SharedWorkerGlobalScope</code> object has an associated
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> object even if that <a href="#cache-host">cache
|
|
host</a> has no actual <a href="#application-cache">application cache</a>.</p>
|
|
|
|
<hr><p>The <dfn id="dom-appcache-status" title="dom-appcache-status"><code>status</code></dfn>
|
|
attribute, on getting, must return the current state of the
|
|
<a href="#application-cache">application cache</a> that the
|
|
<code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache host</a> is
|
|
associated with, if any. This must be the appropriate value from the
|
|
following list:</p>
|
|
|
|
</div><dl><dt><dfn id="dom-appcache-uncached" title="dom-appcache-UNCACHED"><code>UNCACHED</code></dfn>
|
|
(numeric value 0)</dt>
|
|
|
|
<dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
|
|
host</a> is not associated with an <a href="#application-cache">application
|
|
cache</a> at this time.</p></dd>
|
|
|
|
<dt><dfn id="dom-appcache-idle" title="dom-appcache-IDLE"><code>IDLE</code></dfn>
|
|
(numeric value 1)</dt>
|
|
|
|
<dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
|
|
host</a> is associated with an <a href="#application-cache">application cache</a>
|
|
whose <a href="#application-cache-group">application cache group</a>'s <a href="#concept-appcache-status" title="concept-appcache-status">update status</a> is
|
|
<i>idle</i>, and that <a href="#application-cache">application cache</a> is the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> cache in its
|
|
<a href="#application-cache-group">application cache group</a>, and the <a href="#application-cache-group">application
|
|
cache group</a> is not marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>.</p></dd>
|
|
|
|
<dt><dfn id="dom-appcache-checking" title="dom-appcache-CHECKING"><code>CHECKING</code></dfn>
|
|
(numeric value 2)</dt>
|
|
|
|
<dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
|
|
host</a> is associated with an <a href="#application-cache">application cache</a>
|
|
whose <a href="#application-cache-group">application cache group</a>'s <a href="#concept-appcache-status" title="concept-appcache-status">update status</a> is
|
|
<i>checking</i>.</p></dd>
|
|
|
|
<dt><dfn id="dom-appcache-downloading" title="dom-appcache-DOWNLOADING"><code>DOWNLOADING</code></dfn>
|
|
(numeric value 3)</dt>
|
|
|
|
<dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
|
|
host</a> is associated with an <a href="#application-cache">application cache</a>
|
|
whose <a href="#application-cache-group">application cache group</a>'s <a href="#concept-appcache-status" title="concept-appcache-status">update status</a> is
|
|
<i>downloading</i>.</p></dd>
|
|
|
|
<dt><dfn id="dom-appcache-updateready" title="dom-appcache-UPDATEREADY"><code>UPDATEREADY</code></dfn>
|
|
(numeric value 4)</dt>
|
|
|
|
<dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
|
|
host</a> is associated with an <a href="#application-cache">application cache</a>
|
|
whose <a href="#application-cache-group">application cache group</a>'s <a href="#concept-appcache-status" title="concept-appcache-status">update status</a> is
|
|
<i>idle</i>, and whose <a href="#application-cache-group">application cache group</a> is not
|
|
marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>,
|
|
but that <a href="#application-cache">application cache</a> is <em>not</em> the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> cache in its
|
|
group.</p></dd>
|
|
|
|
<dt><dfn id="dom-appcache-obsolete" title="dom-appcache-OBSOLETE"><code>OBSOLETE</code></dfn>
|
|
(numeric value 5)</dt>
|
|
|
|
<dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
|
|
host</a> is associated with an <a href="#application-cache">application cache</a>
|
|
whose <a href="#application-cache-group">application cache group</a> is marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>.</p></dd>
|
|
|
|
</dl><div class="impl">
|
|
|
|
<hr><p>If the <dfn id="dom-appcache-update" title="dom-appcache-update"><code>update()</code></dfn> method is
|
|
invoked, the user agent must invoke the <a href="#application-cache-download-process">application cache
|
|
download process</a>, in the background, for the <a href="#application-cache">application
|
|
cache</a> with which the <code><a href="#applicationcache">ApplicationCache</a></code> object's
|
|
<a href="#cache-host">cache host</a> is associated, but without giving that
|
|
<a href="#cache-host">cache host</a> to the algorithm. If there is no such
|
|
<a href="#application-cache">application cache</a>, or if it is marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>, then the method
|
|
must raise an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception instead.</p>
|
|
|
|
<p>If the <dfn id="dom-appcache-swapcache" title="dom-appcache-swapCache"><code>swapCache()</code></dfn> method
|
|
is invoked, the user agent must run the following steps:
|
|
|
|
</p><ol><li><p>Check that <code><a href="#applicationcache">ApplicationCache</a></code> object's
|
|
<a href="#cache-host">cache host</a> is associated with an <a href="#application-cache">application
|
|
cache</a>. If it is not, then raise an
|
|
<code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these
|
|
steps.</p></li>
|
|
|
|
<li><p>Let <var title="">cache</var> be the <a href="#application-cache">application
|
|
cache</a> with which the <code><a href="#applicationcache">ApplicationCache</a></code> object's
|
|
<a href="#cache-host">cache host</a> is associated. (By definition, this is the
|
|
same as the one that was found in the previous step.)</p></li>
|
|
|
|
<li><p>If <var title="">cache</var>'s <a href="#application-cache-group">application cache
|
|
group</a> is marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>, then unassociate
|
|
the <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache host</a>
|
|
from <var title="">cache</var> and abort these steps. (Resources
|
|
will now load from the network instead of the cache.)</p></li>
|
|
|
|
<li><p>Check that there is an application cache in the same
|
|
<a href="#application-cache-group">application cache group</a> as <var title="">cache</var>
|
|
whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness
|
|
flag</a> is <i>complete</i> and that is <a href="#concept-appcache-newer" title="concept-appcache-newer">newer</a> than <var title="">cache</var>. If there is not, then raise an
|
|
<code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these
|
|
steps.</p></li>
|
|
|
|
<li><p>Let <var title="">new cache</var> be the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> <a href="#application-cache">application
|
|
cache</a> in the same <a href="#application-cache-group">application cache group</a> as
|
|
<var title="">cache</var> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
|
|
<i>complete</i>.</p></li>
|
|
|
|
<li><p>Unassociate the <code><a href="#applicationcache">ApplicationCache</a></code> object's
|
|
<a href="#cache-host">cache host</a> from <var title="">cache</var> and instead
|
|
associate it with <var title="">new cache</var>.</p></li>
|
|
|
|
</ol><p>The following are the <a href="webappapis.html#event-handlers">event handlers</a> (and their
|
|
corresponding <a href="webappapis.html#event-handler-event-type" title="event handler event type">event handler
|
|
event types</a>) that must be supported, as IDL attributes, by
|
|
all objects implementing the <code><a href="#applicationcache">ApplicationCache</a></code>
|
|
interface:</p>
|
|
|
|
<table><thead><tr><th><a href="webappapis.html#event-handlers" title="event handlers">Event handler</a> </th><th><a href="webappapis.html#event-handler-event-type">Event handler event type</a>
|
|
</th></tr></thead><tbody><tr><td><dfn id="handler-appcache-onchecking" title="handler-appcache-onchecking"><code>onchecking</code></dfn> </td><td> <code title="event-appcache-checking"><a href="#event-appcache-checking">checking</a></code>
|
|
</td></tr><tr><td><dfn id="handler-appcache-onerror" title="handler-appcache-onerror"><code>onerror</code></dfn> </td><td> <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code>
|
|
</td></tr><tr><td><dfn id="handler-appcache-onnoupdate" title="handler-appcache-onnoupdate"><code>onnoupdate</code></dfn> </td><td> <code title="event-appcache-noupdate"><a href="#event-appcache-noupdate">noupdate</a></code>
|
|
</td></tr><tr><td><dfn id="handler-appcache-ondownloading" title="handler-appcache-ondownloading"><code>ondownloading</code></dfn> </td><td> <code title="event-appcache-downloading"><a href="#event-appcache-downloading">downloading</a></code>
|
|
</td></tr><tr><td><dfn id="handler-appcache-onprogress" title="handler-appcache-onprogress"><code>onprogress</code></dfn> </td><td> <code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>
|
|
</td></tr><tr><td><dfn id="handler-appcache-onupdateready" title="handler-appcache-onupdateready"><code>onupdateready</code></dfn> </td><td> <code title="event-appcache-updateready"><a href="#event-appcache-updateready">updateready</a></code>
|
|
</td></tr><tr><td><dfn id="handler-appcache-oncached" title="handler-appcache-oncached"><code>oncached</code></dfn> </td><td> <code title="event-appcache-cached"><a href="#event-appcache-cached">cached</a></code>
|
|
</td></tr><tr><td><dfn id="handler-appcache-onobsolete" title="handler-appcache-onobsolete"><code>onobsolete</code></dfn> </td><td> <code title="event-appcache-obsolete"><a href="#event-appcache-obsolete">obsolete</a></code>
|
|
</td></tr></tbody></table></div><h4 id="browser-state"><span class="secno">5.6.10 </span>Browser state</h4><pre class="idl">[Supplemental, NoInterfaceObject]
|
|
interface <dfn id="navigatoronline">NavigatorOnLine</dfn> {
|
|
readonly attribute boolean <a href="#dom-navigator-online" title="dom-navigator-onLine">onLine</a>;
|
|
};</pre><dl class="domintro"><dt><var title="">window</var> . <code title="dom-navigator"><a href="timers.html#dom-navigator">navigator</a></code> . <code title="dom-navigator-onLine"><a href="#dom-navigator-online">onLine</a></code></dt>
|
|
|
|
<dd>
|
|
|
|
<p>Returns false if the user agent is definitely offline
|
|
(disconnected from the network). Returns true if the user agent
|
|
might be online.</p>
|
|
|
|
<p>The events <code title="event-online"><a href="#event-online">online</a></code> and <code title="event-offline"><a href="#event-offline">offline</a></code> are fired when the value of
|
|
this attribute changes.</p>
|
|
|
|
</dd>
|
|
|
|
</dl><div class="impl">
|
|
|
|
<p>The <dfn id="dom-navigator-online" title="dom-navigator-onLine"><code>navigator.onLine</code></dfn>
|
|
attribute must return false if the user agent will not contact the
|
|
network when the user follows links or when a script requests a
|
|
remote page (or knows that such an attempt would fail), and must
|
|
return true otherwise.</p>
|
|
|
|
<p>When the value that would be returned by the <code title="dom-navigator-onLine"><a href="#dom-navigator-online">navigator.onLine</a></code> attribute of a
|
|
<code><a href="browsers.html#window">Window</a></code> or <code>WorkerGlobalScope</code> changes from
|
|
true to false, the user agent must <a href="webappapis.html#queue-a-task">queue a task</a> to
|
|
<a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <dfn id="event-offline" title="event-offline"><code>offline</code></dfn> at the
|
|
<code><a href="browsers.html#window">Window</a></code> or <code>WorkerGlobalScope</code> object.</p>
|
|
|
|
<p>On the other hand, when the value that would be returned by the
|
|
<code title="dom-navigator-onLine"><a href="#dom-navigator-online">navigator.onLine</a></code> attribute
|
|
of a <code><a href="browsers.html#window">Window</a></code> or <code>WorkerGlobalScope</code> changes
|
|
from false to true, the user agent must <a href="webappapis.html#queue-a-task">queue a task</a> to
|
|
<a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <dfn id="event-online" title="event-online"><code>online</code></dfn> at the
|
|
<code><a href="browsers.html#window">Window</a></code> or <code>WorkerGlobalScope</code> object.</p>
|
|
|
|
<p>The <a href="webappapis.html#task-source">task source</a> for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the <a href="webappapis.html#networking-task-source">networking task
|
|
source</a>.</p>
|
|
|
|
</div><p class="note">This attribute is inherently unreliable. A computer
|
|
can be connected to a network without having Internet access.</p><div class="example">
|
|
|
|
<p>In this example, an indicator is updated as the browser goes
|
|
online and offline.</p>
|
|
|
|
<pre><!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Online status</title>
|
|
<script>
|
|
function updateIndicator() {
|
|
document.getElementById('indicator').textContext = navigator.onLine ? 'online' : 'offline';
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="updateIndicator()" ononline="updateIndicator()" onoffline="updateIndicator()">
|
|
<p>The network is: <span id="indicator">(state unknown)</span>
|
|
</body>
|
|
</html></pre>
|
|
|
|
</div></body></html>
|