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.
3355 lines
216 KiB
3355 lines
216 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html lang="en" dir="ltr"><head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>Programmable HTTP Caching and Serving</title>
|
|
<meta name="revision" content="$Id: Overview.html,v 1.5 2011/03/29 14:19:54 mike Exp $">
|
|
|
|
|
|
|
|
|
|
<!--[if IE]>
|
|
<style type='text/css'>
|
|
.ignore {
|
|
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
|
|
filter: alpha(opacity=50);
|
|
}
|
|
</style>
|
|
<![endif]-->
|
|
<style type="text/css">
|
|
h5 {
|
|
display: none
|
|
}
|
|
table {
|
|
border-collapse: collapse;
|
|
border-style: hidden hidden none;
|
|
}
|
|
table thead {
|
|
border-bottom: medium solid;
|
|
}
|
|
table td, table th {
|
|
border-bottom: thin solid;
|
|
border-left: medium solid;
|
|
border-right: medium solid;
|
|
padding: 0.2em;
|
|
vertical-align: top;
|
|
}
|
|
.diff-add {
|
|
background-color: #eeeeee
|
|
}
|
|
</style>
|
|
<style type="text/css">
|
|
/*****************************************************************
|
|
* ReSpec CSS
|
|
* Robin Berjon (robin at berjon dot com)
|
|
* v0.05 - 2009-07-31
|
|
*****************************************************************/
|
|
|
|
|
|
/* --- INLINES --- */
|
|
em.rfc2119 {
|
|
text-transform: lowercase;
|
|
font-variant: small-caps;
|
|
font-style: normal;
|
|
color: #900;
|
|
}
|
|
|
|
h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
|
|
h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
|
|
border: none;
|
|
}
|
|
|
|
dfn {
|
|
font-weight: bold;
|
|
}
|
|
|
|
a.internalDFN {
|
|
color: inherit;
|
|
border-bottom: medium solid #99c;
|
|
text-decoration: none;
|
|
}
|
|
|
|
a.externalDFN {
|
|
color: inherit;
|
|
border-bottom: medium dotted #ccc;
|
|
text-decoration: none;
|
|
}
|
|
|
|
a.bibref {
|
|
text-decoration: none;
|
|
}
|
|
|
|
code {
|
|
color: #ff4500;
|
|
}
|
|
|
|
|
|
/* --- WEB IDL --- */
|
|
pre.idl {
|
|
border-top: 1px solid #90b8de;
|
|
border-bottom: 1px solid #90b8de;
|
|
padding: 1em;
|
|
line-height: 120%;
|
|
}
|
|
|
|
pre.idl::before {
|
|
content: "WebIDL";
|
|
display: block;
|
|
width: 150px;
|
|
background: #90b8de;
|
|
color: #fff;
|
|
font-family: initial;
|
|
padding: 3px;
|
|
font-weight: bold;
|
|
margin: -1em 0 1em -1em;
|
|
}
|
|
|
|
.idlType {
|
|
color: #ff4500;
|
|
font-weight: bold;
|
|
text-decoration: none;
|
|
}
|
|
|
|
/*.idlModule*/
|
|
/*.idlModuleID*/
|
|
/*.idlInterface*/
|
|
.idlInterfaceID {
|
|
font-weight: bold;
|
|
color: #005a9c;
|
|
}
|
|
|
|
.idlSuperclass {
|
|
font-style: italic;
|
|
color: #005a9c;
|
|
}
|
|
|
|
/*.idlAttribute*/
|
|
.idlAttrType, .idlFieldType {
|
|
color: #005a9c;
|
|
}
|
|
.idlAttrName, .idlFieldName {
|
|
color: #ff4500;
|
|
}
|
|
.idlAttrName a, .idlFieldName a {
|
|
color: #ff4500;
|
|
border-bottom: 1px dotted #ff4500;
|
|
text-decoration: none;
|
|
}
|
|
|
|
/*.idlMethod*/
|
|
.idlMethType {
|
|
color: #005a9c;
|
|
}
|
|
.idlMethName {
|
|
color: #ff4500;
|
|
}
|
|
.idlMethName a {
|
|
color: #ff4500;
|
|
border-bottom: 1px dotted #ff4500;
|
|
text-decoration: none;
|
|
}
|
|
|
|
/*.idlParam*/
|
|
.idlParamType {
|
|
color: #005a9c;
|
|
}
|
|
.idlParamName {
|
|
font-style: italic;
|
|
}
|
|
|
|
.extAttr {
|
|
color: #666;
|
|
}
|
|
|
|
/*.idlConst*/
|
|
.idlConstType {
|
|
color: #005a9c;
|
|
}
|
|
.idlConstName {
|
|
color: #ff4500;
|
|
}
|
|
.idlConstName a {
|
|
color: #ff4500;
|
|
border-bottom: 1px dotted #ff4500;
|
|
text-decoration: none;
|
|
}
|
|
|
|
/*.idlException*/
|
|
.idlExceptionID {
|
|
font-weight: bold;
|
|
color: #c00;
|
|
}
|
|
|
|
.idlTypedefID, .idlTypedefType {
|
|
color: #005a9c;
|
|
}
|
|
|
|
.idlRaises, .idlRaises a.idlType, .idlRaises a.idlType code, .excName a, .excName a code {
|
|
color: #c00;
|
|
font-weight: normal;
|
|
}
|
|
|
|
.excName a {
|
|
font-family: monospace;
|
|
}
|
|
|
|
.idlRaises a.idlType, .excName a.idlType {
|
|
border-bottom: 1px dotted #c00;
|
|
}
|
|
|
|
.excGetSetTrue, .excGetSetFalse, .prmNullTrue, .prmNullFalse, .prmOptTrue, .prmOptFalse {
|
|
width: 45px;
|
|
text-align: center;
|
|
}
|
|
.excGetSetTrue, .prmNullTrue, .prmOptTrue { color: #0c0; }
|
|
.excGetSetFalse, .prmNullFalse, .prmOptFalse { color: #c00; }
|
|
|
|
.idlImplements a {
|
|
font-weight: bold;
|
|
}
|
|
|
|
dl.attributes, dl.methods, dl.constants, dl.fields {
|
|
margin-left: 2em;
|
|
}
|
|
|
|
.attributes dt, .methods dt, .constants dt, .fields dt {
|
|
font-weight: normal;
|
|
}
|
|
|
|
.attributes dt code, .methods dt code, .constants dt code, .fields dt code {
|
|
font-weight: bold;
|
|
color: #000;
|
|
font-family: monospace;
|
|
}
|
|
|
|
.attributes dt code, .fields dt code {
|
|
background: #ffffd2;
|
|
}
|
|
|
|
.attributes dt .idlAttrType code, .fields dt .idlFieldType code {
|
|
color: #005a9c;
|
|
background: transparent;
|
|
font-family: inherit;
|
|
font-weight: normal;
|
|
font-style: italic;
|
|
}
|
|
|
|
.methods dt code {
|
|
background: #d9e6f8;
|
|
}
|
|
|
|
.constants dt code {
|
|
background: #ddffd2;
|
|
}
|
|
|
|
.attributes dd, .methods dd, .constants dd, .fields dd {
|
|
margin-bottom: 1em;
|
|
}
|
|
|
|
table.parameters, table.exceptions {
|
|
border-spacing: 0;
|
|
border-collapse: collapse;
|
|
margin: 0.5em 0;
|
|
width: 100%;
|
|
}
|
|
table.parameters { border-bottom: 1px solid #90b8de; }
|
|
table.exceptions { border-bottom: 1px solid #deb890; }
|
|
|
|
.parameters th, .exceptions th {
|
|
color: #fff;
|
|
padding: 3px 5px;
|
|
text-align: left;
|
|
font-family: initial;
|
|
font-weight: normal;
|
|
text-shadow: #666 1px 1px 0;
|
|
}
|
|
.parameters th { background: #90b8de; }
|
|
.exceptions th { background: #deb890; }
|
|
|
|
.parameters td, .exceptions td {
|
|
padding: 3px 10px;
|
|
border-top: 1px solid #ddd;
|
|
vertical-align: top;
|
|
}
|
|
|
|
.parameters tr:first-child td, .exceptions tr:first-child td {
|
|
border-top: none;
|
|
}
|
|
|
|
.parameters td.prmName, .exceptions td.excName, .exceptions td.excCodeName {
|
|
width: 100px;
|
|
}
|
|
|
|
.parameters td.prmType {
|
|
width: 120px;
|
|
}
|
|
|
|
table.exceptions table {
|
|
border-spacing: 0;
|
|
border-collapse: collapse;
|
|
width: 100%;
|
|
}
|
|
|
|
/* --- TOC --- */
|
|
.toc a {
|
|
text-decoration: none;
|
|
}
|
|
|
|
a .secno {
|
|
color: #000;
|
|
}
|
|
|
|
/* --- TABLE --- */
|
|
table.simple {
|
|
border-spacing: 0;
|
|
border-collapse: collapse;
|
|
border-bottom: 3px solid #005a9c;
|
|
}
|
|
|
|
.simple th {
|
|
background: #005a9c;
|
|
color: #fff;
|
|
padding: 3px 5px;
|
|
text-align: left;
|
|
}
|
|
|
|
.simple th[scope="row"] {
|
|
background: inherit;
|
|
color: inherit;
|
|
border-top: 1px solid #ddd;
|
|
}
|
|
|
|
.simple td {
|
|
padding: 3px 10px;
|
|
border-top: 1px solid #ddd;
|
|
}
|
|
|
|
.simple tr:nth-child(even) {
|
|
background: #f0f6ff;
|
|
}
|
|
|
|
/* --- DL --- */
|
|
.section dd > p:first-child {
|
|
margin-top: 0;
|
|
}
|
|
|
|
.section dd > p:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.section dd {
|
|
margin-bottom: 1em;
|
|
}
|
|
|
|
.section dl.attrs dd, .section dl.eldef dd {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
/* --- EXAMPLES --- */
|
|
pre.example {
|
|
border-top: 1px solid #ff4500;
|
|
border-bottom: 1px solid #ff4500;
|
|
padding: 1em;
|
|
margin-top: 1em;
|
|
}
|
|
|
|
pre.example::before {
|
|
content: "Example";
|
|
display: block;
|
|
width: 150px;
|
|
background: #ff4500;
|
|
color: #fff;
|
|
font-family: initial;
|
|
padding: 3px;
|
|
font-weight: bold;
|
|
margin: -1em 0 1em -1em;
|
|
}
|
|
|
|
/* --- EDITORIAL NOTES --- */
|
|
.issue {
|
|
padding: 1em;
|
|
margin: 1em 0em 0em;
|
|
border: 1px solid #f00;
|
|
background: #ffc;
|
|
}
|
|
|
|
.issue::before {
|
|
content: "Issue";
|
|
display: block;
|
|
width: 150px;
|
|
margin: -1.5em 0 0.5em 0;
|
|
font-weight: bold;
|
|
border: 1px solid #f00;
|
|
background: #fff;
|
|
padding: 3px 1em;
|
|
}
|
|
|
|
.note {
|
|
margin: 1em 0em 0em;
|
|
padding: 1em;
|
|
border: 2px solid #cff6d9;
|
|
background: #e2fff0;
|
|
}
|
|
|
|
.note::before {
|
|
content: "Note";
|
|
display: block;
|
|
width: 150px;
|
|
margin: -1.5em 0 0.5em 0;
|
|
font-weight: bold;
|
|
border: 1px solid #cff6d9;
|
|
background: #fff;
|
|
padding: 3px 1em;
|
|
}
|
|
|
|
/* --- Best Practices --- */
|
|
div.practice {
|
|
border: solid #bebebe 1px;
|
|
margin: 2em 1em 1em 2em;
|
|
}
|
|
|
|
span.practicelab {
|
|
margin: 1.5em 0.5em 1em 1em;
|
|
font-weight: bold;
|
|
font-style: italic;
|
|
}
|
|
|
|
span.practicelab { background: #dfffff; }
|
|
|
|
span.practicelab {
|
|
position: relative;
|
|
padding: 0 0.5em;
|
|
top: -1.5em;
|
|
}
|
|
|
|
p.practicedesc {
|
|
margin: 1.5em 0.5em 1em 1em;
|
|
}
|
|
|
|
@media screen {
|
|
p.practicedesc {
|
|
position: relative;
|
|
top: -2em;
|
|
padding: 0;
|
|
margin: 1.5em 0.5em -1em 1em;
|
|
}
|
|
|
|
/* --- SYNTAX HIGHLIGHTING --- */
|
|
pre.sh_sourceCode {
|
|
background-color: white;
|
|
color: black;
|
|
font-style: normal;
|
|
font-weight: normal;
|
|
}
|
|
|
|
pre.sh_sourceCode .sh_keyword { color: #005a9c; font-weight: bold; } /* language keywords */
|
|
pre.sh_sourceCode .sh_type { color: #666; } /* basic types */
|
|
pre.sh_sourceCode .sh_usertype { color: teal; } /* user defined types */
|
|
pre.sh_sourceCode .sh_string { color: red; font-family: monospace; } /* strings and chars */
|
|
pre.sh_sourceCode .sh_regexp { color: orange; font-family: monospace; } /* regular expressions */
|
|
pre.sh_sourceCode .sh_specialchar { color: #ffc0cb; font-family: monospace; } /* e.g., \n, \t, \\ */
|
|
pre.sh_sourceCode .sh_comment { color: #A52A2A; font-style: italic; } /* comments */
|
|
pre.sh_sourceCode .sh_number { color: purple; } /* literal numbers */
|
|
pre.sh_sourceCode .sh_preproc { color: #00008B; font-weight: bold; } /* e.g., #include, import */
|
|
pre.sh_sourceCode .sh_symbol { color: blue; } /* e.g., *, + */
|
|
pre.sh_sourceCode .sh_function { color: black; font-weight: bold; } /* function calls and declarations */
|
|
pre.sh_sourceCode .sh_cbracket { color: red; } /* block brackets (e.g., {, }) */
|
|
pre.sh_sourceCode .sh_todo { font-weight: bold; background-color: #00FFFF; } /* TODO and FIXME */
|
|
|
|
/* Predefined variables and functions (for instance glsl) */
|
|
pre.sh_sourceCode .sh_predef_var { color: #00008B; }
|
|
pre.sh_sourceCode .sh_predef_func { color: #00008B; font-weight: bold; }
|
|
|
|
/* for OOP */
|
|
pre.sh_sourceCode .sh_classname { color: teal; }
|
|
|
|
/* line numbers (not yet implemented) */
|
|
pre.sh_sourceCode .sh_linenum { display: none; }
|
|
|
|
/* Internet related */
|
|
pre.sh_sourceCode .sh_url { color: blue; text-decoration: underline; font-family: monospace; }
|
|
|
|
/* for ChangeLog and Log files */
|
|
pre.sh_sourceCode .sh_date { color: blue; font-weight: bold; }
|
|
pre.sh_sourceCode .sh_time, pre.sh_sourceCode .sh_file { color: #00008B; font-weight: bold; }
|
|
pre.sh_sourceCode .sh_ip, pre.sh_sourceCode .sh_name { color: #006400; }
|
|
|
|
/* for Prolog, Perl... */
|
|
pre.sh_sourceCode .sh_variable { color: #006400; }
|
|
|
|
/* for LaTeX */
|
|
pre.sh_sourceCode .sh_italics { color: #006400; font-style: italic; }
|
|
pre.sh_sourceCode .sh_bold { color: #006400; font-weight: bold; }
|
|
pre.sh_sourceCode .sh_underline { color: #006400; text-decoration: underline; }
|
|
pre.sh_sourceCode .sh_fixed { color: green; font-family: monospace; }
|
|
pre.sh_sourceCode .sh_argument { color: #006400; }
|
|
pre.sh_sourceCode .sh_optionalargument { color: purple; }
|
|
pre.sh_sourceCode .sh_math { color: orange; }
|
|
pre.sh_sourceCode .sh_bibtex { color: blue; }
|
|
|
|
/* for diffs */
|
|
pre.sh_sourceCode .sh_oldfile { color: orange; }
|
|
pre.sh_sourceCode .sh_newfile { color: #006400; }
|
|
pre.sh_sourceCode .sh_difflines { color: blue; }
|
|
|
|
/* for css */
|
|
pre.sh_sourceCode .sh_selector { color: purple; }
|
|
pre.sh_sourceCode .sh_property { color: blue; }
|
|
pre.sh_sourceCode .sh_value { color: #006400; font-style: italic; }
|
|
|
|
/* other */
|
|
pre.sh_sourceCode .sh_section { color: black; font-weight: bold; }
|
|
pre.sh_sourceCode .sh_paren { color: red; }
|
|
pre.sh_sourceCode .sh_attribute { color: #006400; }
|
|
|
|
</style><link href="DataCache.css" rel="stylesheet" type="text/css" charset="utf-8"><link href="http://www.w3.org/StyleSheets/TR/W3C-WG-NOTE" rel="stylesheet" type="text/css" charset="utf-8"></head>
|
|
<body style="display: inherit; "><div class="head"><p><a href="http://www.w3.org/"><img width="72" height="48" src="http://www.w3.org/Icons/w3c_home" alt="W3C"></a></p><h1 class="title" id="title">Programmable HTTP Caching and Serving</h1><h2 id="w3c-working-group-note-29-march-2011">W3C Working Group Note 29 March 2011</h2><dl><dt>This version:</dt><dd><a href="http://www.w3.org/TR/2011/NOTE-DataCache-20110329/">http://www.w3.org/TR/2011/NOTE-DataCache-20110329/</a></dd><dt>Latest published version:</dt><dd><a href="http://www.w3.org/TR/DataCache/">http://www.w3.org/TR/DataCache/</a></dd>
|
|
<dt>Previous version:</dt><dd><a href="http://www.w3.org/TR/2010/WD-DataCache-20100114/">http://www.w3.org/TR/2010/WD-DataCache-20100114/</a></dd><dt>Editor:</dt><dd><a href="mailto:nikunj@o-micron.com">Nikunj Mehta</a>, Invited Expert</dd>
|
|
</dl><p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2011 <a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href="http://www.ercim.eu/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p><hr></div>
|
|
<div id="abstract" class="introductory section"><h2>Abstract</h2>
|
|
<p>
|
|
This document defines APIs for off-line serving of requests to HTTP resources using
|
|
static and dynamic responses. It extends the function of application caches defined in
|
|
HTML5.
|
|
</p>
|
|
</div><div id="sotd" class="introductory section"><h2>Status of This Document</h2><p style="background: black; color: white; font: 900 2em serif; padding: 0.5em 1em; border: dotted yellow 0.5em; text-align: center">Beware.
|
|
This specification is no longer in active maintenance and the
|
|
Web Applications Working Group does not intend to maintain it further.
|
|
</p><p><em>This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the <a href="http://www.w3.org/TR/">W3C technical reports index</a> at http://www.w3.org/TR/.</em></p><p>This document was published by the <a href="http://www.w3.org/2008/webapps/">Web Applications Working Group</a> as a Working Group Note. If you wish to make comments regarding this document, please send them to <a href="mailto:public-webapps@w3.org">public-webapps@w3.org</a> (<a href="mailto:public-webapps-request@w3.org?subject=subscribe">subscribe</a>, <a href="http://lists.w3.org/Archives/Public/public-webapps/">archives</a>). All feedback is welcome.</p><p>Publication as a Working Group Note does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.</p><p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>. W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/42538/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.</p></div><div id="toc" class="section"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a href="#introduction" class="tocxref"><span class="secno">1. </span>Introduction</a></li><li class="tocline"><a href="#conformance" class="tocxref"><span class="secno">2. </span>Conformance</a><ul class="toc"><li class="tocline"><a href="#dependencies" class="tocxref"><span class="secno">2.1 </span>Dependencies</a></li></ul></li><li class="tocline"><a href="#terminology" class="tocxref"><span class="secno">3. </span>Terminology</a></li><li class="tocline"><a href="#cache" class="tocxref"><span class="secno">4. </span>Programmable HTTP Caching and Serving</a><ul class="toc"><li class="tocline"><a href="#datacache-intro" class="tocxref"><span class="secno">4.1 </span>Introduction</a><ul class="toc"><li class="tocline"><a href="#examples" class="tocxref"><span class="secno">4.1.1 </span>Examples</a></li><li class="tocline"><a href="#cache-events" class="tocxref"><span class="secno">4.1.2 </span>Event summary</a></li></ul></li><li class="tocline"><a href="#http-cache" class="tocxref"><span class="secno">4.2 </span>Programmable HTTP Caching</a><ul class="toc"><li class="tocline"><a href="#starting-a-transaction" class="tocxref"><span class="secno">4.2.1 </span>Starting a transaction</a></li><li class="tocline"><a href="#adding-capture-transaction" class="tocxref"><span class="secno">4.2.2 </span>Capturing resources</a></li><li class="tocline"><a href="#release-resource" class="tocxref"><span class="secno">4.2.3 </span>Releasing resources</a></li><li class="tocline"><a href="#complete-transaction" class="tocxref"><span class="secno">4.2.4 </span>Commiting a transaction</a></li><li class="tocline"><a href="#abort-transaction" class="tocxref"><span class="secno">4.2.5 </span>Aborting a transaction</a></li><li class="tocline"><a href="#datacache-api" class="tocxref"><span class="secno">4.2.6 </span>The API Entry Point</a></li><li class="tocline"><a href="#request-events" class="tocxref"><span class="secno">4.2.7 </span>Asynchronous requests</a></li><li class="tocline"><a href="#extending-the-applicationcache-interface" class="tocxref"><span class="secno">4.2.8 </span>Extending the <code>ApplicationCache</code> interface</a></li><li class="tocline"><a href="#events-and-error" class="tocxref"><span class="secno">4.2.9 </span>The <code>CacheEvent</code> Interface</a></li></ul></li><li class="tocline"><a href="#local-server" class="tocxref"><span class="secno">4.3 </span>Programmable HTTP Serving</a><ul class="toc"><li class="tocline"><a href="#request-interface" class="tocxref"><span class="secno">4.3.1 </span>Local Server Interfaces</a></li><li class="tocline"><a href="#networking-model-changes" class="tocxref"><span class="secno">4.3.2 </span>Changes to the networking model</a></li></ul></li></ul></li><li class="tocline"><a href="#security" class="tocxref"><span class="secno">5. </span>Security Considerations</a></li><li class="tocline"><a href="#acknowledgements" class="tocxref"><span class="secno">A. </span>Acknowledgements</a></li><li class="tocline"><a href="#references" class="tocxref"><span class="secno">B. </span>References</a><ul class="toc"><li class="tocline"><a href="#normative-references" class="tocxref"><span class="secno">B.1 </span>Normative references</a></li><li class="tocline"><a href="#informative-references" class="tocxref"><span class="secno">B.2 </span>Informative references</a></li></ul></li></ul></div>
|
|
|
|
<div id="introduction" class="section informative">
|
|
<!--OddPage--><h2><span class="secno">1. </span>Introduction</h2><p><em>This section is non-normative.</em></p>
|
|
<p>
|
|
The existing cache manifest [<cite><a class="bibref" rel="biblioentry" href="#bib-HTML5">HTML5</a></cite>] statically identifies cached
|
|
resources to be stored in an application cache. The API introduced
|
|
in this document extends the application cache by allowing
|
|
applications to programmatically add other resources to the cache
|
|
which can then be served by the user agent when that resource is
|
|
requested. This API also extends the application cache to enable
|
|
applications to programmatically generate responses to requests for
|
|
resources that have been added to the application cache. As a result,
|
|
the application cache can now be used to satisfy unsafe HTTP methods
|
|
such as <code>PUT</code> and <code>POST</code>.
|
|
</p>
|
|
<p>
|
|
Using this application cache extension, applications can obtain locally
|
|
cached data or data produced locally by JavaScript servers and perform
|
|
requests on resources that can be served whether or not the user agent
|
|
is connected to a remote server. Applications can then save and replay
|
|
locally satisfied requests to the server when it is reconnected, thus
|
|
enabling responsive and robust Web applications in the presence of low
|
|
connectivity conditions.
|
|
</p>
|
|
<p>
|
|
This specification does not require a new programming model for Web
|
|
applications as application caches can be configured to be transparently
|
|
pressed into action by the user agent, depending on system conditions.
|
|
Such applications can seamlessly switch between on-line and off-line
|
|
operation without needing explicit user action. This also means that
|
|
existing applications can be used unchanged in many cases
|
|
once the application cache is configured. Applications only need to be
|
|
altered to use APIs specified in this document if they require more
|
|
complex synchronization.
|
|
</p>
|
|
</div>
|
|
|
|
<div id="conformance" class="section"><!--OddPage--><h2><span class="secno">2. </span>Conformance</h2><p>As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.</p>
|
|
<p>The key words <em class="rfc2119" title="must">must</em>, <em class="rfc2119" title="must not">must not</em>, <em class="rfc2119" title="required">required</em>, <em class="rfc2119" title="should">should</em>, <em class="rfc2119" title="should not">should not</em>, <em class="rfc2119" title="recommended">recommended</em>, <em class="rfc2119" title="may">may</em>, and <em class="rfc2119" title="optional">optional</em> in this specification are to be interpreted as described in [<cite><a class="bibref" rel="biblioentry" href="#bib-RFC2119">RFC2119</a></cite>].</p>
|
|
|
|
<p>
|
|
This specification defines one class of products:
|
|
</p>
|
|
<dl>
|
|
<dt><dfn id="dfn-conforming-user-agent">conforming user agent</dfn></dt>
|
|
<dd>
|
|
<p>
|
|
A user agent must behave as described in this specification
|
|
in order to be considered conformant.
|
|
</p>
|
|
|
|
<p>
|
|
User agents may implement algorithms given in this
|
|
specification in any way desired, so long as the end result is
|
|
indistinguishable from the result that would be obtained by the
|
|
specification's algorithms.
|
|
</p>
|
|
|
|
<p>
|
|
A <a href="#dfn-conforming-user-agent" class="internalDFN">conforming user agent</a> must also be a
|
|
<em>conforming implementation</em> of the IDL fragments
|
|
of this specification, as described in the
|
|
Web IDL specification. [<cite><a class="bibref" rel="biblioentry" href="#bib-WEBIDL">WEBIDL</a></cite>]
|
|
</p>
|
|
|
|
<p class="note">
|
|
This specification uses both the terms "conforming user agent(s)"
|
|
and "user agent(s)" to refer to this product class.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<div id="dependencies" class="section">
|
|
<h3><span class="secno">2.1 </span>Dependencies</h3>
|
|
|
|
<p>This specification relies on several underlying specifications.</p>
|
|
<dl>
|
|
<dt>HTML5</dt>
|
|
<dd>The terms and algorithms
|
|
<dfn title="event handler" id="dfn-event-handler">event handlers</dfn>,
|
|
<dfn id="dfn-event-handler-event-type">event handler event type</dfn>, <dfn id="dfn-origin">origin</dfn>,
|
|
<dfn id="dfn-same-origin">same origin</dfn>, <dfn id="dfn-fetching-resources">fetching resources</dfn>,
|
|
<dfn id="dfn-browsing-context">browsing context</dfn>, <dfn id="dfn-active-document">active document</dfn>,
|
|
<dfn id="dfn-child-browsing-context">child browsing context</dfn>, <dfn id="dfn-application-cache">application cache</dfn>,
|
|
<dfn id="dfn-application-cache-group">application cache group</dfn>, <dfn id="dfn-relevant-application-cache">relevant application cache</dfn>,
|
|
<dfn id="dfn-master-entries">master entries</dfn>, <dfn id="dfn-application-cache-selection-algorithm">application cache selection algorithm</dfn>,
|
|
<dfn id="dfn-cache-host">cache host</dfn>, <dfn id="dfn-manifest">manifest</dfn>, <dfn id="dfn-explicit-entries">explicit entries</dfn>,
|
|
<dfn id="dfn-http-get-equivalent">HTTP GET equivalent</dfn>, <dfn id="dfn-task">task</dfn>, <dfn id="dfn-task-source">task source</dfn>,
|
|
and <dfn id="dfn-queue-a-task">queue a task</dfn>, <dfn id="dfn-storage-mutex">storage mutex</dfn>, the
|
|
<dfn id="dfn-manifest-1"><code>manifest</code></dfn> attribute, and the
|
|
<dfn id="dfn-function"><code>Function</code></dfn> and <dfn id="dfn-applicationcache"><code>ApplicationCache</code></dfn>
|
|
interfaces are referenced in this specification and defined by the HTML 5
|
|
specification [<cite><a class="bibref" rel="biblioentry" href="#bib-HTML5">HTML5</a></cite>].
|
|
</dd>
|
|
<dt>HTTP</dt>
|
|
<dd>
|
|
<p>
|
|
A <a href="#dfn-conforming-user-agent" class="internalDFN"> conforming user agent</a> must support some version of the
|
|
HTTP protocol [<cite><a class="bibref" rel="biblioentry" href="#bib-HTTP11">HTTP11</a></cite>].
|
|
</p>
|
|
|
|
<p>
|
|
In order to protect against attacks, the use of the following
|
|
headers is prohibited using interfaces defined in this specification.
|
|
</p>
|
|
|
|
<ul>
|
|
<li><code>Accept</code></li>
|
|
|
|
<li><code>Accept-Charset</code></li>
|
|
|
|
<li><code>Accept-Encoding</code></li>
|
|
|
|
<li><code>Accept-Language</code></li>
|
|
|
|
<li><code>Authorization</code></li>
|
|
|
|
<li><code>Cache-Control</code></li>
|
|
|
|
<li><code>Connection</code></li>
|
|
|
|
<li><code>Content-Transfer-Encoding</code></li>
|
|
|
|
<li><code>Cookie</code></li>
|
|
|
|
<li><code>Date</code></li>
|
|
|
|
<li><code>Expect</code></li>
|
|
|
|
<li><code>Host</code></li>
|
|
|
|
<li><code>Keep-Alive</code></li>
|
|
|
|
<li><code>Origin</code></li>
|
|
|
|
<li><code>Range</code></li>
|
|
|
|
<li><code>Referer</code></li>
|
|
|
|
<li><code>Set-Cookie</code></li>
|
|
|
|
<li><code>TE</code></li>
|
|
|
|
<li><code>Trailer</code></li>
|
|
|
|
<li><code>Transfer-Encoding</code></li>
|
|
|
|
<li><code>Upgrade</code></li>
|
|
|
|
<li><code>User-Agent</code></li>
|
|
|
|
<li><code>Via</code></li>
|
|
</ul>
|
|
</dd>
|
|
<dt>HTTP State Management</dt>
|
|
<dd>
|
|
<p>
|
|
A <a href="#dfn-conforming-user-agent" class="internalDFN">conforming user agent</a> must support storage and
|
|
exchange of cookies as specified by HTTP State Management
|
|
[<cite><a class="bibref" rel="biblioentry" href="#bib-COOKIES">COOKIES</a></cite>].
|
|
</p>
|
|
</dd>
|
|
<dt>File API</dt>
|
|
<dd>The term
|
|
<dfn title="Blob" id="dfn-blob"><code>Blob</code></dfn> is referenced by this
|
|
specification and defined by the File API specification [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-API">FILE-API</a></cite>].
|
|
</dd><dt>DOM</dt>
|
|
<dd>
|
|
<p>
|
|
A <a href="#dfn-conforming-user-agent" class="internalDFN">conforming user agent</a> must define the exception codes
|
|
<dfn id="dfn-invalid_state_err"><code>INVALID_STATE_ERR</code></dfn> and
|
|
<dfn id="dfn-not_found_err"><code>NOT_FOUND_ERR</code></dfn>, and
|
|
<dfn id="dfn-event"><code>Event</code></dfn> and <dfn id="dfn-domexception"><code>DOMException</code></dfn>
|
|
interface defined in [<cite><a class="bibref" rel="biblioentry" href="#bib-DOM-LEVEL-3-CORE">DOM-LEVEL-3-CORE</a></cite>]
|
|
and referenced in this specification.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="terminology" class="section">
|
|
<!--OddPage--><h2><span class="secno">3. </span>Terminology</h2>
|
|
<p>
|
|
A <dfn id="dfn-managed">managed</dfn> resource is one whose URI is dynamically captured
|
|
in an <a class="externalDFN">application cache</a>.
|
|
</p>
|
|
|
|
<p>
|
|
A resource is <dfn id="dfn-captured">captured</dfn> when it is dynamically added
|
|
to an <a class="externalDFN">application cache</a>.
|
|
</p>
|
|
|
|
<p>
|
|
A resource is <dfn id="dfn-released">released</dfn> when it is dynamically removed
|
|
from an <a class="externalDFN">application cache</a>.
|
|
</p>
|
|
|
|
<p>
|
|
A <dfn id="dfn-static">static</dfn> representation is one that is generated directly
|
|
by the user agent from an <a class="externalDFN">application cache</a>.
|
|
</p>
|
|
|
|
<p>
|
|
A <dfn id="dfn-dynamic">dynamic</dfn> representation is one that is generated
|
|
programmatically by using application-supplied logic
|
|
in an embedded local server.
|
|
</p>
|
|
|
|
<p>
|
|
<dfn title="off-line" id="dfn-off-line">Transparent off-line data access and manipulation</dfn>
|
|
means to locally generate a <a href="#dfn-static" class="internalDFN">static</a> or a <a href="#dfn-dynamic" class="internalDFN">dynamic</a>
|
|
response for HTTP requests to <a href="#event-captured" class="internalDFN">captured</a> resources.
|
|
</p>
|
|
</div>
|
|
|
|
<div id="cache" class="section">
|
|
<!--OddPage--><h2><span class="secno">4. </span>Programmable HTTP Caching and Serving</h2>
|
|
|
|
<p>
|
|
Programmable HTTP processing enables applications to identify
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resources to a user agent and to produce <a href="#dfn-static" class="internalDFN">static</a>
|
|
and <a href="#dfn-dynamic" class="internalDFN">dynamic</a> representations for responding to requests on
|
|
these resources.
|
|
</p>
|
|
|
|
<div id="datacache-intro" class="section informative">
|
|
<h3><span class="secno">4.1 </span>Introduction</h3><p><em>This section is non-normative.</em></p>
|
|
|
|
<p>
|
|
A user agent processes network requests to <a>managed resources</a>
|
|
in one of three ways:
|
|
</p>
|
|
<ol>
|
|
<li>
|
|
<dfn id="dfn-serve-policy">serve policy</dfn> - respond with the <a href="#dfn-static" class="internalDFN">static</a> representation
|
|
of the requested resource (for any safe HTTP methods) from
|
|
the <a class="externalDFN">application cache</a>.
|
|
</li>
|
|
<li>
|
|
<dfn id="dfn-intercept-policy">intercept policy</dfn> -
|
|
immediately invoke an <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a> to obtain a
|
|
<a href="#dfn-dynamic" class="internalDFN">dynamic</a> representation (for any HTTP methods).
|
|
</li>
|
|
<li>
|
|
<dfn id="dfn-review-policy">review policy</dfn> -
|
|
relay the request to the server to obtain a <a href="#dfn-dynamic" class="internalDFN">dynamic</a>
|
|
representation and notify an <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a>
|
|
when that representation is available (only for unsafe HTTP methods).
|
|
</li>
|
|
</ol>
|
|
|
|
<p>
|
|
The <a href="#dfn-serve-policy" class="internalDFN">serve policy</a> applies only to resources that do not
|
|
require interception, whereas the <a href="#dfn-intercept-policy" class="internalDFN">intercept policy</a> can only
|
|
be used for resources that require interception. Both policies
|
|
improve availability and responsiveness. However, both may affect
|
|
data freshness. The <a href="#dfn-review-policy" class="internalDFN">review policy</a>
|
|
can only be used when the user agent is able to communicate with
|
|
the server. This policy improves data freshness at the cost of
|
|
reduced responsiveness. User agents may choose freely from among
|
|
these options, e.g., using information about the system condition,
|
|
network state or battery power level, or a user preference.
|
|
</p>
|
|
|
|
<div class="section" id="examples">
|
|
<h4><span class="secno">4.1.1 </span>Examples</h4>
|
|
|
|
<p>
|
|
An application can use an <a class="externalDFN">application cache</a> to
|
|
programmatically <a title="captured" href="#event-captured" class="internalDFN">capture</a> the representation of a
|
|
resource, i.e., cache an <a href="#dfn-off-line" class="internalDFN">off-line</a> representation in the
|
|
<a class="externalDFN">application cache</a>.
|
|
</p>
|
|
|
|
<div class="example"><div class="exampleHeader">Example</div>
|
|
<p>
|
|
An application <a>captures</a> a resource as part of an atomic
|
|
<a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>. Once the resource is <a href="#event-captured" class="internalDFN">captured</a>
|
|
successfully, the application places the <a href="#event-captured" class="internalDFN">captured</a>
|
|
representation in to service. This can be performed through a
|
|
single API call.
|
|
</p>
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var uri = ...
|
|
var cache = window.applicationCache;
|
|
// cache and immediately take advantage of the new stuff in the cache
|
|
cache.immediate(uri);</code></pre></div></div>
|
|
<p>
|
|
The user agent is able to then serve this <a href="#dfn-static" class="internalDFN">static</a> representation
|
|
when an application issues a <code>GET</code> request for
|
|
that resource either through page navigation or an XMLHttpRequest
|
|
[<cite><a class="bibref" rel="biblioentry" href="#bib-XMLHTTPREQUEST">XMLHTTPREQUEST</a></cite>].
|
|
</p>
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var req = new XMLHttpRequest();
|
|
req.open('GET', uri);
|
|
...
|
|
req.send();</code></pre></div></div>
|
|
</div>
|
|
|
|
<p>
|
|
A <a href="#dfn-dynamic" class="internalDFN">dynamic</a> representation is produced by using an
|
|
<a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a> in conjunction with the
|
|
<a class="externalDFN">application cache</a>. An <a href="#dfn-interceptor" class="internalDFN">interceptor</a>
|
|
processes an HTTP request locally in an <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a>
|
|
without changing the network APIs used by applications. Thus
|
|
even if a host is unreachable, applications can successfully
|
|
make HTTP requests to a <a href="#dfn-managed" class="internalDFN">managed</a> resource.
|
|
</p>
|
|
|
|
<div class="example"><div class="exampleHeader">Example</div>
|
|
<p>
|
|
In this example, a local request handler can produce a <a href="#dfn-dynamic" class="internalDFN">dynamic</a>
|
|
response to an application request when the network is not accessible.
|
|
The response can be prepared using the
|
|
<a class="externalDFN">application cache</a>, for example. The benefit
|
|
of this technique is that applications don't need to alter their
|
|
applications to accommodate <a href="#dfn-off-line" class="internalDFN">off-line</a> use cases.
|
|
Instead, user agents can transparently introduce an application-specific
|
|
<a href="#dfn-off-line" class="internalDFN">off-line</a> handler to deal with situations when the network is not
|
|
available.
|
|
</p>
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var uri = ...
|
|
var cache = window.applicationCache;
|
|
var local = function(request, response) {
|
|
response.setStatus(200, 'OK');
|
|
response.setResponseText('Hello World');
|
|
};
|
|
|
|
window.navigator.registerOfflineHandler(uri, local);
|
|
|
|
var req = cache.offline(uri, '', null, ['GET']);</code></pre></div></div>
|
|
<p>
|
|
Later when that application issues a <code>GET</code> request for
|
|
the <a href="#dfn-managed" class="internalDFN">managed</a> resource either through page navigation or an XMLHttpRequest
|
|
[<cite><a class="bibref" rel="biblioentry" href="#bib-XMLHTTPREQUEST">XMLHTTPREQUEST</a></cite>], and the user agent is <a href="#dfn-off-line" class="internalDFN">off-line</a>, it invokes the
|
|
<code>local</code> <a href="#dfn-off-line" class="internalDFN">off-line</a> handler which produces a <a href="#dfn-dynamic" class="internalDFN">dynamic</a>
|
|
response.
|
|
</p>
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var req = new XMLHttpRequest();
|
|
req.open('GET', uri);
|
|
...
|
|
req.send();</code></pre></div></div>
|
|
</div>
|
|
|
|
<p>
|
|
Applications can also locally intercept requests that modify data,
|
|
e.g., unsafe HTTP requests such as <code>PUT</code> in an <a href="#dfn-off-line" class="internalDFN">off-line</a>
|
|
handler. Requests to resources that are <a href="#dfn-managed" class="internalDFN">managed</a> in an
|
|
<a class="externalDFN">application cache</a> can be either:
|
|
</p>
|
|
<ul>
|
|
<li>intercepted and served by an <a href="#dfn-interceptor" class="internalDFN">interceptor</a>, when the
|
|
user agent is <a href="#dfn-off-line" class="internalDFN">off-line</a> or</li>
|
|
<li>the server, when the user agent is online with a <a href="#dfn-reviewer" class="internalDFN">reviewer</a>
|
|
analyzing the result of the online request.</li>
|
|
</ul>
|
|
<p>
|
|
A user agent can switch
|
|
between these two behaviors automatically based on system conditions.
|
|
</p>
|
|
|
|
<div class="example"><div class="exampleHeader">Example</div>
|
|
<p>
|
|
For example, an application worker script that wishes to allow <a href="#dfn-off-line" class="internalDFN">off-line</a>
|
|
updates to <var>uri</var> <a title="captured" href="#event-captured" class="internalDFN">captures</a> that resource
|
|
in an <a class="externalDFN">application cache</a>.
|
|
</p>
|
|
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var uri = ...
|
|
var cache = self.applicationCache;
|
|
cache.immediate(uri, ['PUT']);
|
|
</code></pre></div></div>
|
|
|
|
<p>
|
|
Another application in the same origin could then register an <a href="#dfn-off-line" class="internalDFN">off-line</a>
|
|
handler for the same <var>uri</var> to serve <a href="#dfn-off-line" class="internalDFN">off-line</a> requests to
|
|
that resource.
|
|
</p>
|
|
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var cache = window.applicationCache;
|
|
var intercept = function(request, response) {
|
|
if (...) {
|
|
// validation fails
|
|
response.setStatus(400, 'Bad Request');
|
|
response.setResponseText('Request not understood');
|
|
return;
|
|
}
|
|
var type = request.headers['Content-Type'] || 'text/plain';
|
|
var req = cache.offline(request.targetURL, request.bodyText, type);
|
|
req.onsuccess = function() {
|
|
response.setResponseText(request.bodyText);
|
|
response.setResponseHeader('Content-Type', type);
|
|
response.setStatus(200, 'OK');
|
|
}
|
|
};
|
|
|
|
var review = function(request, response) {
|
|
var req = cache.offline(request.targetURL, response.bodyText, response.headers['Content-Type']);
|
|
};
|
|
|
|
window.navigator.registerOfflineHandler(uri, intercept, review);</code></pre></div></div>
|
|
|
|
<p>
|
|
When the application makes a <code>PUT</code> request to
|
|
<var>uri</var> and the user agent is <a href="#dfn-off-line" class="internalDFN">off-line</a>,
|
|
the user agent asks the <var>intercept</var> function to
|
|
process the request and respond to it. If the user agent is online
|
|
when the request arrives, then it sends the request to
|
|
a host and asks the <var>review</var> function to process the
|
|
response received from it.
|
|
</p>
|
|
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var req = new XMLHttpRequest();
|
|
req.open('PUT', uri);
|
|
...
|
|
req.send(...);</code></pre></div></div>
|
|
|
|
<p>
|
|
If this application makes a <code>GET</code> request to
|
|
<var>uri</var>, then its cached <a href="#dfn-static" class="internalDFN">static</a> representation is
|
|
returned as the response regardless of whether the user agent is off-line.
|
|
</p>
|
|
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var req = new XMLHttpRequest();
|
|
req.open('GET', uri);
|
|
...
|
|
req.send();</code></pre></div></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="cache-events" class="section informative">
|
|
<h4><span class="secno">4.1.2 </span>Event summary</h4><p><em>This section is non-normative.</em></p>
|
|
|
|
<p>
|
|
An application updates the <a href="#dfn-managed" class="internalDFN">managed</a> resources of an
|
|
<a class="externalDFN">application cache</a>. During this update, the
|
|
user agent will add or remove the representations of <a href="#dfn-managed" class="internalDFN">managed</a>
|
|
resources to and from the <a class="externalDFN">application cache</a>.
|
|
</p>
|
|
|
|
<p>
|
|
As this is going on, a number of events get fired to keep the script
|
|
updated as to the state of the <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>, so that the
|
|
user can be notified appropriately. The events are as follows:
|
|
</p>
|
|
|
|
<table>
|
|
<thead><tr><th>Event name</th><th>Occasion</th><th>Next events</th></tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><dfn id="event-captured"><code>captured</code></dfn></td>
|
|
<td>
|
|
The user agent has finished <a title="fetch">fetching</a>
|
|
and storing the representation of a <a href="#dfn-managed" class="internalDFN">managed</a> resource.
|
|
</td>
|
|
<td>
|
|
<a href="#event-captured"><code>captured</code></a>,
|
|
<a href="#event-released"><code>released</code></a>,
|
|
<a href="#event-ready"><code>ready</code></a>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><dfn id="event-released"><code>released</code></dfn></td>
|
|
<td>The user agent has released a <a href="#dfn-managed" class="internalDFN">managed</a> resource
|
|
and can no longer serve <a href="#dfn-off-line" class="internalDFN">off-line</a> requests to it.</td>
|
|
<td>
|
|
<a href="#event-captured"><code>captured</code></a>,
|
|
<a href="#event-released"><code>released</code></a>,
|
|
<a href="#event-ready"><code>ready</code></a>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><dfn id="event-ready"><code>ready</code></dfn></td>
|
|
<td>The user agent has finished capturing and releasing the
|
|
requested resources and does not have any pending
|
|
requests in this <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>.</td>
|
|
<td>Last event in sequence.</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="http-cache" class="section">
|
|
<h3><span class="secno">4.2 </span>Programmable HTTP Caching</h3>
|
|
|
|
<p>
|
|
This specification adds two new kinds of entries for
|
|
<a class="externalDFN">application cache</a> to the various kinds
|
|
defined in [<cite><a class="bibref" rel="biblioentry" href="#bib-HTML5">HTML5</a></cite>]:
|
|
</p>
|
|
|
|
<dl>
|
|
<dt><dfn id="dfn-static-entry">static entry</dfn></dt>
|
|
<dd>
|
|
A <a href="#dfn-managed" class="internalDFN">managed</a> resource whose representation is cached for
|
|
<a href="#dfn-off-line" class="internalDFN">off-line</a> serving. A request to a <a href="#dfn-static-entry" class="internalDFN">static entry</a>
|
|
can only be used with the <a href="#dfn-serve-policy" class="internalDFN">serve policy</a>.
|
|
</dd>
|
|
<dt><dfn id="dfn-dynamic-entry">dynamic entry</dfn></dt>
|
|
<dd>
|
|
A <a href="#dfn-managed" class="internalDFN">managed</a> resource whose representation is produced locally
|
|
by an application upon request. Each <a href="#dfn-dynamic-entry" class="internalDFN">dynamic entry</a>
|
|
identifies one or more <dfn id="dfn-dynamic-methods">dynamic methods</dfn>
|
|
for which a response can be obtained locally using an
|
|
<a href="#dfn-interceptor" class="internalDFN">interceptor</a>.
|
|
</dd>
|
|
</dl>
|
|
|
|
<div class="note">
|
|
Only a document with a manifest can use <a href="#dfn-managed" class="internalDFN">managed</a> resources.
|
|
</div>
|
|
|
|
<p>
|
|
Each <a class="externalDFN">application cache</a> has a
|
|
<dfn id="dfn-dynamic-completeness-flag">dynamic completeness flag</dfn>, which is either
|
|
<var>incomplete</var> or <var>complete</var>.
|
|
Each <a class="externalDFN">application cache</a> whose
|
|
<a href="#dfn-dynamic-completeness-flag" class="internalDFN">dynamic completeness flag</a>
|
|
is <var>complete</var> has a <dfn id="dfn-version">version</dfn>.
|
|
No two <a class="externalDFN">application cache</a>s in an
|
|
<a class="externalDFN">application cache group</a>
|
|
may have the same <a href="#dfn-version" class="internalDFN">version</a>. A <a class="externalDFN">newer</a>
|
|
<a class="externalDFN">application cache</a> has a larger <a href="#dfn-version" class="internalDFN">version</a>.
|
|
</p>
|
|
|
|
<p>
|
|
Each <a class="externalDFN">application cache group</a> has a
|
|
<dfn id="dfn-dynamic-update-status">dynamic update status</dfn>, which is one of the following:
|
|
<var>idle</var> or <var>updating</var>.
|
|
</p>
|
|
|
|
<p>
|
|
Application scripts identify the resources <a href="#dfn-managed" class="internalDFN">managed</a> by an
|
|
<a class="externalDFN">application cache</a> during a <dfn id="dfn-cache-transaction">cache transaction</dfn>,
|
|
when applications may either <a title="captured" href="#event-captured" class="internalDFN">capture</a> or
|
|
<a title="released" href="#event-released" class="internalDFN">release</a> its resources.
|
|
</p>
|
|
|
|
<p>
|
|
Each <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> has an
|
|
<a class="externalDFN">application cache group</a>
|
|
and an <a class="externalDFN">application cache</a>.
|
|
</p>
|
|
|
|
<p>
|
|
A <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> can be marked as
|
|
<dfn id="dfn-off-line-transaction">off-line transaction</dfn>.
|
|
</p>
|
|
|
|
<p>
|
|
Each <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> has a <dfn id="dfn-commit-status">commit status</dfn>,
|
|
which can be either of <var>pending</var>, <var>committed</var>, or
|
|
<var>aborted</var>.
|
|
</p>
|
|
|
|
<p>
|
|
When a <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> is started, the user agent must run
|
|
the steps to <a href="#dfn-create-a-cache-transaction" class="internalDFN">create a cache transaction</a>. When a resource is
|
|
added to a transaction's list of <a href="#event-captured" class="internalDFN">captured</a> resources,
|
|
the user agent must run the steps to <a href="#dfn-add-a-resource-to-be-captured" class="internalDFN">add a resource to be captured</a>.
|
|
When a resource is added to a transaction's list of released
|
|
resources, the user agent must run the steps to
|
|
<a href="#dfn-add-a-resource-to-be-released" class="internalDFN">add a resource to be released</a>. When the transaction is finished,
|
|
the user agent must run either the steps to <a href="#dfn-commit-a-cache-transaction" class="internalDFN">commit a cache transaction</a>
|
|
or the steps to <a href="#dfn-abort-a-cache-transaction" class="internalDFN">abort a cache transaction</a>.
|
|
</p>
|
|
|
|
<div class="section" id="starting-a-transaction">
|
|
<h4><span class="secno">4.2.1 </span>Starting a transaction</h4>
|
|
|
|
<p>
|
|
When the user agent is required to <dfn id="dfn-create-a-cache-transaction">create a cache transaction</dfn>
|
|
given an <a class="externalDFN">application cache group</a> and an
|
|
off-line flag, the user agent must run the following steps:
|
|
</p>
|
|
|
|
<ol>
|
|
<li>
|
|
Let <var>cache group</var> be the
|
|
<a class="externalDFN">application cache group</a> passed to these steps.
|
|
</li>
|
|
<li>
|
|
If <var>cache group</var> is marked <a>obsolete</a>, then
|
|
set an error and abort these steps.
|
|
</li>
|
|
<li>
|
|
Pick the appropriate steps:
|
|
<dl class="switch">
|
|
<dt>If the off-line flag passed to these steps is set.</dt>
|
|
<dd>
|
|
<ol>
|
|
<li>
|
|
Create a new <a class="externalDFN">application cache</a>,
|
|
called <var>cache</var>, in <var>cache group</var>.
|
|
</li>
|
|
<li>
|
|
Set the <a href="#dfn-dynamic-completeness-flag" class="internalDFN">dynamic completeness flag</a> of <var>cache</var> to
|
|
<var>incomplete</var>.
|
|
</li>
|
|
<li>
|
|
Create a new <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> called <var>transaction</var> and
|
|
set <var>cache</var> to be its
|
|
<a class="externalDFN">application cache</a>.
|
|
</li>
|
|
<li>
|
|
Mark <var>transaction</var> as <a href="#dfn-off-line-transaction" class="internalDFN">off-line transaction</a>.
|
|
</li>
|
|
<li>
|
|
Return <var>transaction</var>.
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
|
|
<dt>If the off-line flag passed to these steps is not set.</dt>
|
|
<dd>
|
|
<ol>
|
|
<li>
|
|
Atomically, so as to avoid race conditions, perform the following sub-steps
|
|
<ol>
|
|
<li>
|
|
If the <a href="#dfn-dynamic-update-status" class="internalDFN">dynamic update status</a> of
|
|
<var>cache group</var> is <var>updating</var>,
|
|
then set an error and abort these steps, as a
|
|
<a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> is already open on this
|
|
<a class="externalDFN">application cache group</a>.
|
|
</li>
|
|
<li>
|
|
Set the <a href="#dfn-dynamic-update-status" class="internalDFN">dynamic update status</a> of <var>cache group</var>
|
|
to <var>updating</var>.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
Create a new <a class="externalDFN">application cache</a>,
|
|
called <var>cache</var>, in <var>cache group</var>
|
|
which holds all the same resources as the
|
|
<a class="externalDFN">relevant application cache</a> of
|
|
<var>cache group</var>.
|
|
</li>
|
|
<li>
|
|
Set the <a href="#dfn-dynamic-completeness-flag" class="internalDFN">dynamic completeness flag</a> of <var>cache</var> to
|
|
<var>incomplete</var>.
|
|
</li>
|
|
<li>
|
|
Create a new <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> called <var>transaction</var> and
|
|
set <var>cache</var> to be its <a class="externalDFN">application cache</a>.
|
|
</li>
|
|
<li>
|
|
Mark <var>transaction</var> as not <a title="off-line transaction" href="#dfn-off-line-transaction" class="internalDFN">off-line</a>.
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
</dl></li>
|
|
<li>
|
|
Set <var>transaction</var>'s <a href="#dfn-commit-status" class="internalDFN">commit status</a> to
|
|
<var>pending</var>.
|
|
</li>
|
|
<li>
|
|
Return <var>transaction</var>.
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<div class="section" id="adding-capture-transaction">
|
|
<h4><span class="secno">4.2.2 </span>Capturing resources</h4>
|
|
|
|
<p>
|
|
When the user agent is required to <dfn id="dfn-add-a-resource-to-be-captured">add a resource to be
|
|
<a href="#event-captured" class="internalDFN">captured</a></dfn>, given the URI of the resource to
|
|
<a title="captured" href="#event-captured" class="internalDFN">capture</a>, a <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>,
|
|
optionally a list of <a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a>, optionally content to
|
|
serve as the <a href="#dfn-static" class="internalDFN">static</a> representation of that resource, and
|
|
optionally content type for that representation, the user agent
|
|
must perform the following steps:
|
|
</p>
|
|
|
|
<ol>
|
|
<li>
|
|
Let <var>transaction</var> be the <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>
|
|
passed to these steps.
|
|
</li>
|
|
|
|
<li>
|
|
If <var>transaction</var>'s <a href="#dfn-commit-status" class="internalDFN">commit status</a> is not
|
|
<var>pending</var>, then set an error and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
Pick the appropriate sub-steps:
|
|
<dl class="switch">
|
|
<dt>If the <a class="externalDFN">cache host</a> passed to
|
|
these steps is a <code>Document</code> object</dt>
|
|
<dd>
|
|
Let <var>origin</var> be the <a href="#dfn-origin" class="internalDFN">origin</a> of the
|
|
<a class="externalDFN">cache host</a> passed to these steps.
|
|
</dd>
|
|
|
|
<dt>If the <a class="externalDFN">cache host</a> passed to
|
|
these steps is a <code>WorkerGlobalScope</code> object</dt>
|
|
<dd>
|
|
Let <var>origin</var> be the <a href="#dfn-origin" class="internalDFN">origin</a> of the scripts in the
|
|
worker for the <a class="externalDFN">cache host</a> passed to
|
|
these steps.
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
|
|
<li>
|
|
Resolve the URI passed to these steps relative to <var>base URI</var>.
|
|
</li>
|
|
|
|
<li>
|
|
If the resulting absolute URI has a different <code><scheme></code>
|
|
component than the base URI (compared in an ASCII case-insensitive
|
|
manner), then set an error and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
If the resulting absolute URI does not have the
|
|
<a class="externalDFN">same origin</a> as <var>base URI</var>,
|
|
then set an error and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
Drop the <code><fragment></code> component of the resulting
|
|
absolute URI, if it has one.
|
|
</li>
|
|
|
|
<li>
|
|
Let <var>cache</var> be <var>transaction</var>'s
|
|
<a class="externalDFN">application cache</a>.
|
|
</li>
|
|
|
|
<li>
|
|
If the resulting absolute URI identifies an
|
|
<a class="externalDFN">explicit entry</a> or
|
|
<a class="externalDFN">master entry</a> or the
|
|
<a class="externalDFN"> manifest</a> of <var>cache</var>, then
|
|
set an error and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
If the resulting absolute URI identifies a <a href="#dfn-managed" class="internalDFN">managed</a> resource that
|
|
is already in <var>cache</var>, then remove that <a href="#dfn-managed" class="internalDFN">managed</a>
|
|
resource from <var>cache</var>.
|
|
</li>
|
|
<li>
|
|
Pick the appropriate sub-steps: <dl class="switch">
|
|
<dt>
|
|
If <var>transaction</var> is not marked as
|
|
<a title="off-line transaction" href="#dfn-off-line-transaction" class="internalDFN">off-line</a>
|
|
</dt>
|
|
<dd>
|
|
<ol>
|
|
<li>
|
|
If the list of dynamic methods passed to these steps
|
|
includes the method <code>GET</code>, then skip the
|
|
remaining sub-steps and store in <var>cache</var> a
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource comprising the resulting absolute
|
|
URI and the list of
|
|
<a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a> passed to these steps.
|
|
</li>
|
|
<li>
|
|
<a title="fetch">Fetch</a> the representation of the resource identified by the
|
|
absolute URI. Use the <var>transaction</var>'s
|
|
<a class="externalDFN">application cache</a> 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 class="note">
|
|
If the resource in question is already being <a title="fetch">fetched</a>
|
|
for other reasons, then the existing download process can
|
|
sometimes be used for the purposes of this step.
|
|
</p>
|
|
</li>
|
|
|
|
<li>
|
|
If the previous step fails (e.g. the server returns a 4xx
|
|
or 5xx response or equivalent, 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
|
|
<a href="#dfn-capture-failure-steps" class="internalDFN">capture failure steps</a> with the status code of the
|
|
previous step and terminate these steps.
|
|
<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 URIs that differ
|
|
from any URI that the networking model will allow access
|
|
to, leaving orphan entries; or would allow resources to
|
|
be stored under URIs different than their true URIs. All
|
|
of these situations are bad.
|
|
</p>
|
|
</li>
|
|
|
|
<li>
|
|
Otherwise, the <a class="externalDFN">fetching</a> succeeded.
|
|
Store in <var>cache</var> a
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource comprising the resulting absolute URI,
|
|
its <a title="fetch">fetched</a> representation, and the list of
|
|
<a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a> passed to these steps.
|
|
</li>
|
|
|
|
</ol>
|
|
</dd>
|
|
<dt>
|
|
If <var>transaction</var> is marked as
|
|
<a title="off-line transaction" href="#dfn-off-line-transaction" class="internalDFN">off-line</a>.
|
|
</dt>
|
|
<dd>
|
|
<ol>
|
|
<li>
|
|
If the list of dynamic methods passed to these steps
|
|
includes the method <code>GET</code>, then skip the
|
|
remaining sub-steps and store in <var>cache</var> a
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource comprising the resulting absolute
|
|
URI and the list of
|
|
<a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a> passed to these steps.
|
|
</li>
|
|
<li>
|
|
Let <var>representation</var> be the content passed
|
|
to these steps.
|
|
</li>
|
|
<li>
|
|
Let <var>type</var> be the content type passed to these steps.
|
|
</li>
|
|
<li>
|
|
If <var>type</var> is empty or null, set it to <code>text/plain</code>.
|
|
</li>
|
|
<li>
|
|
Store in <var>cache</var> a <a href="#dfn-managed" class="internalDFN">managed</a> resource comprising
|
|
the resulting absolute URI, <var>representation</var>, and the list of
|
|
<a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a> passed to these
|
|
steps.
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
</dl></li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event at
|
|
<var>transaction</var> for the URI passed to these steps with the
|
|
name <a href="#event-captured"><code>captured</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a href="#idl-def-CacheEvent" class="idlType"><code>CacheEvent</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
|
|
<p>
|
|
The <dfn id="dfn-capture-failure-steps">capture failure steps</dfn> are performed with a status
|
|
code as follows:
|
|
</p>
|
|
|
|
<ol>
|
|
<li>Discard <var>cache</var>.</li>
|
|
<li>
|
|
Set <var>cache group</var>'s <a href="#dfn-dynamic-update-status" class="internalDFN">dynamic update status</a>
|
|
to <var>idle</var>.
|
|
</li>
|
|
<li>Pick the appropriate sub-steps:
|
|
<dl class="switch">
|
|
<dt>If the status code was not <code>404</code> or <code>410</code>
|
|
<a class="externalDFN">or equivalent</a>, then</dt>
|
|
<dd>
|
|
Skip this resource and <a>release</a> it from
|
|
<var>application cache</var>.
|
|
</dd>
|
|
<dt>Otherwise</dt>
|
|
<dd>
|
|
Set the error code to the status code passed to these steps.
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
<li>
|
|
Mark <var>transaction</var>'s <a href="#dfn-commit-status" class="internalDFN">commit status</a>
|
|
as <var>aborted</var>.
|
|
</li>
|
|
</ol>
|
|
|
|
<p>
|
|
Attempts to <a>fetch</a> resources as part of the steps to
|
|
<a href="#dfn-add-a-resource-to-be-captured" class="internalDFN">add a resource to be captured</a>
|
|
may be done with cache-defeating semantics, to avoid problems with
|
|
stale or inconsistent intermediary caches.
|
|
</p>
|
|
</div>
|
|
|
|
<div class="section" id="release-resource">
|
|
<h4><span class="secno">4.2.3 </span>Releasing resources</h4>
|
|
|
|
<p>
|
|
When the user agent is required to
|
|
<dfn id="dfn-add-a-resource-to-be-released">add a resource to be <a href="#event-released" class="internalDFN">released</a></dfn>, given the URI of
|
|
the resource to <a title="released" href="#event-released" class="internalDFN">release</a>, and a
|
|
<a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>,
|
|
the user agent must perform the following steps:
|
|
</p>
|
|
|
|
<ol>
|
|
<li>
|
|
Let <var>transaction</var> be the <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>
|
|
passed to these steps.
|
|
</li>
|
|
|
|
<li>
|
|
If <var>transaction</var>'s <a href="#dfn-commit-status" class="internalDFN">commit status</a> is not
|
|
<var>pending</var>, then set an error and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
Pick the appropriate sub-steps:
|
|
<dl class="switch">
|
|
<dt>If the <a class="externalDFN">cache host</a> passed to
|
|
these steps is a <code>Document</code> object</dt>
|
|
<dd>
|
|
Let <var>origin</var> be the <a href="#dfn-origin" class="internalDFN">origin</a> of the
|
|
<a class="externalDFN">cache host</a> passed to these steps.
|
|
</dd>
|
|
|
|
<dt>If the <a class="externalDFN">cache host</a> passed to
|
|
these steps is a <code>WorkerGlobalScope</code> object</dt>
|
|
<dd>
|
|
Let <var>origin</var> be the <a href="#dfn-origin" class="internalDFN">origin</a> of the scripts
|
|
in the worker for the <a class="externalDFN">cache host</a>
|
|
passed to these steps.
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
|
|
<li>
|
|
Resolve the URI passed to these steps relative to <var>base URI</var>.
|
|
</li>
|
|
|
|
<li>
|
|
If the resulting absolute URI has a different <code><scheme></code>
|
|
component than the base URI (compared in an ASCII case-insensitive
|
|
manner), then set an error and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
If the resulting absolute URI does not have the same <a href="#dfn-origin" class="internalDFN">origin</a>
|
|
as <var>base URI</var>, then set an error and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
Drop the <code><fragment></code> component of the resulting
|
|
absolute URI, if it has one.
|
|
</li>
|
|
|
|
<li>
|
|
Let <var>cache</var> be <var>transaction</var>'s
|
|
<a class="externalDFN">application cache</a>.
|
|
</li>
|
|
|
|
<li>
|
|
If the resulting absolute URI does not identify a <a href="#dfn-managed" class="internalDFN">managed</a>
|
|
resource that is already in <var>cache</var>, then set an error
|
|
and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
Remove the <a href="#dfn-managed" class="internalDFN">managed</a>
|
|
resource for the resulting absolute URI from <var>cache</var>.
|
|
</li>
|
|
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event at
|
|
<var>transaction</var> for the URI passed to these steps with the
|
|
name <a href="#event-released"><code>released</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a href="#idl-def-CacheEvent" class="idlType"><code>CacheEvent</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<div class="section" id="complete-transaction">
|
|
<h4><span class="secno">4.2.4 </span>Commiting a transaction</h4>
|
|
|
|
<p>
|
|
When the user agent is required to
|
|
<dfn id="dfn-commit-a-cache-transaction">commit a cache transaction</dfn>, given a <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>,
|
|
it means that the user agent must run the following steps:
|
|
</p>
|
|
|
|
<ol>
|
|
<li>
|
|
Let <var>transaction</var> be the
|
|
<a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> passed to these steps.
|
|
</li>
|
|
|
|
<li>
|
|
If <var>transaction</var>'s <a href="#dfn-commit-status" class="internalDFN">commit status</a> is not
|
|
<var>pending</var>, then set an error and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
Let <var>cache</var> be <var>transaction</var>'s
|
|
<a class="externalDFN">application cache</a>.
|
|
</li>
|
|
|
|
<li>
|
|
Let <var>cache group</var> be the
|
|
<a class="externalDFN">application cache group</a> containing
|
|
<var>cache</var>.
|
|
</li>
|
|
|
|
<li>
|
|
Atomically, so as to avoid race conditions, perform the following
|
|
sub-steps:
|
|
<ol>
|
|
<li>
|
|
Let <var>cache group version</var> be the <a href="#dfn-version" class="internalDFN">version</a> of the
|
|
<a class="externalDFN">relevant application cache</a> of
|
|
<var>cache group</var>.
|
|
</li>
|
|
<li>
|
|
Set <var>cache</var>'s <a href="#dfn-version" class="internalDFN">version</a>
|
|
to be higher than <var>cache group version</var>.
|
|
</li>
|
|
<li>
|
|
Set the <var>cache</var>'s <a href="#dfn-dynamic-completeness-flag" class="internalDFN">dynamic completeness flag</a> to
|
|
<var>complete</var>.
|
|
</li>
|
|
<li>Obtain the <a href="#dfn-storage-mutex" class="internalDFN">storage mutex</a>.</li>
|
|
<li>
|
|
If the host sets cookies in response to such a request,
|
|
the user agent should update its cookie store accordingly.
|
|
</li>
|
|
<li>Release the <a href="#dfn-storage-mutex" class="internalDFN">storage mutex</a>.</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
Pick the appropriate sub-steps:
|
|
<dl class="switch">
|
|
<dt>
|
|
If <var>transaction</var> is marked as
|
|
<a title="off-line transaction" class="dfnref internalDFN" href="#dfn-off-line-transaction">off-line</a>, then
|
|
</dt>
|
|
<dd>
|
|
<ol>
|
|
<li>
|
|
Make <var>cache</var> the
|
|
<a class="externalDFN">effective application cache</a> for
|
|
<var>cache group</var> to the
|
|
<a class="externalDFN">cache host</a>
|
|
passed to these steps.
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
<dt>
|
|
If <var>transaction</var> is not marked as
|
|
<a title="off-line transaction" class="dfnref internalDFN" href="#dfn-off-line-transaction">off-line</a>, then
|
|
</dt>
|
|
<dd>
|
|
<ol>
|
|
<li>
|
|
Set the <a href="#dfn-dynamic-update-status" class="internalDFN">dynamic update status</a> of <var>cache group</var>
|
|
to <var>idle</var>.
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
</dl>
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event at <var>transaction</var>
|
|
with the name <a href="#event-ready"><code>ready</code></a>,
|
|
which does not bubble, is not cancelable, and which uses the
|
|
<a href="#dfn-event" class="internalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
|
|
<li>
|
|
Set <var>transaction</var>'s <a href="#dfn-commit-status" class="internalDFN">commit status</a> as <var>committed</var>.
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<div class="section" id="abort-transaction">
|
|
<h4><span class="secno">4.2.5 </span>Aborting a transaction</h4>
|
|
|
|
<p>
|
|
When the user agent is required to <dfn id="dfn-abort-a-cache-transaction">abort a cache transaction</dfn>,
|
|
given a <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>,
|
|
it means that the user agent must run the following steps:
|
|
</p>
|
|
|
|
<ol>
|
|
<li>
|
|
Let <var>transaction</var> be the <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>
|
|
passed to these steps.
|
|
</li>
|
|
|
|
<li>
|
|
If <var>transaction</var>'s <a href="#dfn-commit-status" class="internalDFN">commit status</a> is not
|
|
<var>pending</var>, then set an error and abort these steps.
|
|
</li>
|
|
|
|
<li>
|
|
Discard <var>transaction</var>'s <a class="externalDFN">application cache</a>.
|
|
</li>
|
|
|
|
<li>
|
|
Set <var>transaction</var>'s <a href="#dfn-commit-status" class="internalDFN">commit status</a> as
|
|
<var>aborted</var>.
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<div class="section" id="datacache-api">
|
|
<h4><span class="secno">4.2.6 </span>The API Entry Point</h4>
|
|
<div class="example"><div class="exampleHeader">Example</div>
|
|
<p>
|
|
Here's how a shared worker opens an
|
|
<a class="externalDFN">application cache group</a>.
|
|
</p>
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var cache = self.applicationCache;</code></pre></div></div>
|
|
<p>
|
|
Here's how a window opens an
|
|
<a class="externalDFN">application cache group</a>.
|
|
</p>
|
|
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var cache = window.applicationCache;</code></pre></div></div>
|
|
</div>
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-CacheUtil">[<span class="extAttr">Supplemental</span>]
|
|
interface <span class="idlInterfaceID">CacheUtil</span> {
|
|
<span class="idlAttribute"> attribute <span class="idlAttrType"><a href="#idl-def-ApplicationCache2Request" class="idlType"><code>ApplicationCache2Request</code></a></span> <span class="idlAttrName"><a href="#widl-CacheUtil-applicationCache">applicationCache</a></span>;</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="attributes">Attributes</h5><dl class="attributes"><dt id="widl-CacheUtil-applicationCache"><code>applicationCache</code> of type <span class="idlAttrType"><a href="#idl-def-ApplicationCache2Request" class="idlType"><code>ApplicationCache2Request</code></a></span></dt><dd>
|
|
<p>
|
|
(In a window.) Returns the <a href="#idl-def-ApplicationCache2Request" class="idlType"><code>ApplicationCache2Request</code></a>
|
|
object that applies to the <a class="externalDFN">active document</a>
|
|
of that <a class="externalDFN"><code>Window</code></a>.
|
|
</p>
|
|
<p>
|
|
(In a shared worker.) Returns the <a href="#idl-def-ApplicationCache2Request" class="idlType"><code>ApplicationCache2Request</code></a>
|
|
object that applies to the current shared worker.
|
|
</p>
|
|
<div><em>No exceptions.</em></div></dd></dl></div>
|
|
|
|
<pre class="idl"><span class="idlImplements"><a>Window</a> implements <a href="#idl-def-CacheUtil" class="idlType"><code>CacheUtil</code></a>;</span></pre><div class="idlImplementsDesc"><p>All instances of the <code><a>Window</a></code> type are defined to also implement the <a href="#idl-def-CacheUtil" class="idlType"><code>CacheUtil</code></a> interface.</p></div>
|
|
<pre class="idl"><span class="idlImplements"><a>WorkerGlobalScope</a> implements <a href="#idl-def-CacheUtil" class="idlType"><code>CacheUtil</code></a>;</span></pre><div class="idlImplementsDesc"><p>All instances of the <code><a>WorkerGlobalScope</a></code> type are defined to also implement the <a href="#idl-def-CacheUtil" class="idlType"><code>CacheUtil</code></a> interface.</p></div>
|
|
|
|
<!--dl class="idl" title="[Supplemental] interface CacheUtilSync">
|
|
<dt>attribute ApplicationCache2Re applicationCache</dt>
|
|
<dd>
|
|
(In a shared worker.) Returns the <a><code>ApplicationCache2Sync</code></a>
|
|
object that applies to the current shared worker.
|
|
</dd>
|
|
</dl-->
|
|
</div>
|
|
|
|
<div id="request-events" class="section">
|
|
<h4><span class="secno">4.2.7 </span>Asynchronous requests</h4>
|
|
<p>
|
|
Events are fired during asynchronous access as <a href="#dfn-managed" class="internalDFN">managed</a>
|
|
resources are accessed and manipulated. As requests are made for
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resources, the user agent processes them and saves
|
|
or retrieves data from the network or storage, and when the
|
|
required data is available, it alerts the application through the
|
|
firing of events. The events are as follows:
|
|
</p>
|
|
<table style="margin-bottom: 0.5em;">
|
|
<thead><tr><th>Event name</th><th>Dispatched when...</th></tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><dfn id="event-success"><code>success</code></dfn></td>
|
|
<td>The <a class="externalDFN">application cache</a> request has
|
|
been completed and its results are available.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><dfn id="event-error"><code>error</code></dfn></td>
|
|
<td>There was an error performing the
|
|
<a class="externalDFN">application cache</a> request.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-AppCacheRequest">interface <span class="idlInterfaceID">AppCacheRequest</span> {
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-AppCacheRequest-abort">abort</a></span> ();</span>
|
|
<span class="idlConst"> const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-AppCacheRequest-INITIAL">INITIAL</a></span> = <span class="idlConstValue">0</span>;</span>
|
|
<span class="idlConst"> const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-AppCacheRequest-LOADING">LOADING</a></span> = <span class="idlConstValue">1</span>;</span>
|
|
<span class="idlConst"> const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-AppCacheRequest-DONE">DONE</a></span> = <span class="idlConstValue">2</span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>unsigned short</a></span> <span class="idlAttrName"><a href="#widl-AppCacheRequest-readyState">readyState</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>any</a></span> <span class="idlAttrName"><a href="#widl-AppCacheRequest-error">error</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>any</a></span> <span class="idlAttrName"><a href="#widl-AppCacheRequest-result">result</a></span>;</span>
|
|
<span class="idlAttribute"> attribute <span class="idlAttrType"><a>Function</a></span> <span class="idlAttrName"><a href="#widl-AppCacheRequest-onsuccess">onsuccess</a></span>;</span>
|
|
<span class="idlAttribute"> attribute <span class="idlAttrType"><a>Function</a></span> <span class="idlAttrName"><a href="#widl-AppCacheRequest-onerror">onerror</a></span>;</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="attributes-1">Attributes</h5><dl class="attributes"><dt id="widl-AppCacheRequest-error"><code>error</code> of type <span class="idlAttrType"><a>any</a></span>, readonly</dt><dd>The error that occurred during the execution of this request<div><em>No exceptions.</em></div></dd><dt id="widl-AppCacheRequest-onerror"><code>onerror</code> of type <span class="idlAttrType"><a>Function</a></span></dt><dd>The <a class="externalDFN">event handler</a> for the
|
|
<a href="#event-error"><code>error</code></a> event<div><em>No exceptions.</em></div></dd><dt id="widl-AppCacheRequest-onsuccess"><code>onsuccess</code> of type <span class="idlAttrType"><a>Function</a></span></dt><dd>The <a class="externalDFN">event handler</a> for the
|
|
<a href="#event-success"><code>success</code></a> event<div><em>No exceptions.</em></div></dd><dt id="widl-AppCacheRequest-readyState"><code>readyState</code> of type <span class="idlAttrType"><a>unsigned short</a></span>, readonly</dt><dd>The completion state of this request<div><em>No exceptions.</em></div></dd><dt id="widl-AppCacheRequest-result"><code>result</code> of type <span class="idlAttrType"><a>any</a></span>, readonly</dt><dd>The result of a successful completion of the request<div><em>No exceptions.</em></div></dd></dl></div><div class="section"><h5 id="methods">Methods</h5><dl class="methods"><dt id="widl-AppCacheRequest-abort"><code>abort</code></dt><dd>Discontinue the in-flight request and return the
|
|
<a href="#widl-AppCacheRequest-readyState"><code>readyState</code></a> to
|
|
<a href="#widl-AppCacheRequest-INITIAL"><code>INITIAL</code></a>. No
|
|
<a href="#widl-AppCacheRequest-result"><code>result</code></a> or
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a> is
|
|
set.<div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div><div class="section"><h5 id="constants">Constants</h5><dl class="constants"><dt id="widl-AppCacheRequest-DONE"><code>DONE</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>This state indicates that a result to a previous request is
|
|
available in the
|
|
<a href="#widl-AppCacheRequest-result"><code>result</code></a> or
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
attribute.</dd><dt id="widl-AppCacheRequest-INITIAL"><code>INITIAL</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>This state indicates that a request has not been started.</dd><dt id="widl-AppCacheRequest-LOADING"><code>LOADING</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>This state indicates that a request has been started but its
|
|
result is not yet available.</dd></dl></div>
|
|
</div>
|
|
|
|
<div class="section" id="extending-the-applicationcache-interface">
|
|
<h4><span class="secno">4.2.8 </span>Extending the <code>ApplicationCache</code> interface</h4>
|
|
<p>
|
|
Additional metadata is available about an
|
|
<a class="externalDFN">application cache</a> through the
|
|
<a href="#idl-def-ApplicationCache2" class="idlType"><code>ApplicationCache2</code></a>.
|
|
</p>
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-ApplicationCache2">interface <span class="idlInterfaceID">ApplicationCache2</span> : <span class="idlSuperclass"><a>ApplicationCache</a></span> {
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>unsigned long</a></span> <span class="idlAttrName"><a href="#widl-ApplicationCache-version">version</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>unsigned long long</a></span> <span class="idlAttrName"><a href="#widl-ApplicationCache-size">size</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>long long</a></span> <span class="idlAttrName"><a href="#widl-ApplicationCache-lastRefresh">lastRefresh</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>unsigned long</a></span> <span class="idlAttrName"><a href="#widl-ApplicationCache-pendingUpdates">pendingUpdates</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>DOMString</a></span> <span class="idlAttrName"><a href="#widl-ApplicationCache-outbox">outbox</a></span>;</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="attributes-2">Attributes</h5><dl class="attributes"><dt id="widl-ApplicationCache-lastRefresh"><code>lastRefresh</code> of type <span class="idlAttrType"><a>long long</a></span>, readonly</dt><dd>The number of milliseconds since the midnight of January 1, 1970
|
|
that elapsed till the time this
|
|
<a class="externalDFN">application cache</a> was last refreshed<div><em>No exceptions.</em></div></dd><dt id="widl-ApplicationCache-outbox"><code>outbox</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>The URL for processing items in the outbox of the application
|
|
using this <a class="externalDFN">application cache</a><div><em>No exceptions.</em></div></dd><dt id="widl-ApplicationCache-pendingUpdates"><code>pendingUpdates</code> of type <span class="idlAttrType"><a>unsigned long</a></span>, readonly</dt><dd>A count of the approximate number of updates that are pending for
|
|
the application<div><em>No exceptions.</em></div></dd><dt id="widl-ApplicationCache-size"><code>size</code> of type <span class="idlAttrType"><a>unsigned long long</a></span>, readonly</dt><dd>The approximate number of bytes occupied by this
|
|
<a class="externalDFN">application cache</a>.<div><em>No exceptions.</em></div></dd><dt id="widl-ApplicationCache-version"><code>version</code> of type <span class="idlAttrType"><a>unsigned long</a></span>, readonly</dt><dd>The <a href="#dfn-version" class="internalDFN">version</a> of this <a class="externalDFN">application cache</a><div><em>No exceptions.</em></div></dd></dl></div>
|
|
|
|
<div class="note">
|
|
Interactions with an <a class="externalDFN">application cache</a>
|
|
cause background network and storage processing. Since these
|
|
actions can take time, an asynchronous request-based API is
|
|
specified here.
|
|
</div>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-ApplicationCache2Request">interface <span class="idlInterfaceID">ApplicationCache2Request</span> : <span class="idlSuperclass"><a href="#idl-def-ApplicationCache2" class="idlType"><code>ApplicationCache2</code></a></span> {
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-ApplicationCacheRequest-setOutbox">setOutbox</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">uri</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-ApplicationCacheRequest-immediate">immediate</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">uri</span></span>, <span class="idlParam">in optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">dynamicMethods</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-ApplicationCacheRequest-offline">offline</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">uri</span></span>, <span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">body</span></span>, <span class="idlParam">in optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">contentType</span></span>, <span class="idlParam">in optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">dynamicMethods</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-ApplicationCacheRequest-transaction">transaction</a></span> (<span class="idlParam">in optional <span class="idlParamType"><a>boolean</a></span> <span class="idlParamName">restart</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-ApplicationCacheRequest-offlineTransaction">offlineTransaction</a></span> ();</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-CacheCursorRequest" class="idlType"><code>CacheCursorRequest</code></a></span> <span class="idlMethName"><a href="#widl-ApplicationCacheRequest-openModifiedItemCursor">openModifiedItemCursor</a></span> (<span class="idlParam">in <span class="idlParamType"><a>long</a></span> <span class="idlParamName">version</span></span>) raises (<span class="idlRaises"><a>DOMException</a></span>);</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="methods-1">Methods</h5><dl class="methods"><dt id="widl-ApplicationCacheRequest-immediate"><code>immediate</code></dt><dd>
|
|
When this method is called, the user agent returns immediately
|
|
with a new <a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called
|
|
<var>result</var> and asynchronously performs the following steps:
|
|
<ol>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-create-a-cache-transaction" class="internalDFN">create a cache transaction</a>
|
|
using this <a class="externalDFN">application cache group</a>
|
|
and an unset off-line flag. Call the returned
|
|
<a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> as <var>transaction</var>.
|
|
</li>
|
|
<li>
|
|
If there was an error while starting a <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>,
|
|
then perform the following sub-steps and skip the remaining steps:
|
|
<ol>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error of the previous step.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-add-a-resource-to-be-captured" class="internalDFN">add a resource to be captured</a>
|
|
with the URI passed to these steps, <var>transaction</var>,
|
|
and the dynamic methods passed to these steps.
|
|
</li>
|
|
<li>
|
|
If there was an error while capturing, then perform the
|
|
following sub-steps and skip the remaining steps:
|
|
<ol>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error of the previous step.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
<li>
|
|
Switch to the <a class="externalDFN">newest application cache</a>
|
|
in this <a class="externalDFN">application cache group</a>.
|
|
</li>
|
|
</ol>
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">uri</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">identifying the resource to <a title="captured" href="#event-captured" class="internalDFN">capture</a></td></tr><tr><td class="prmName">dynamicMethods</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">
|
|
The <a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a> that are applicable to the identified
|
|
resource. This parameter is a comma separated list of protocol
|
|
methods that can be intercepted for local processing. An empty
|
|
string is allowed for this parameter.
|
|
</td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd><dt id="widl-ApplicationCacheRequest-offline"><code>offline</code></dt><dd>
|
|
When this method is called, the user agent returns immediately
|
|
with a new <a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called
|
|
<var>result</var> and asynchronously performs the following steps:
|
|
<ol>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-create-a-cache-transaction" class="internalDFN">create a cache transaction</a>
|
|
using this <a class="externalDFN">application cache group</a>
|
|
and a set off-line flag. Call the returned
|
|
<a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> as <var>transaction</var>.
|
|
</li>
|
|
<li>
|
|
If there was an error while starting a <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>,
|
|
then perform the following sub-steps and skip the remaining steps:
|
|
<ol>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error of the previous step.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-add-a-resource-to-be-captured" class="internalDFN">add a resource to be captured</a>
|
|
with the URI passed to these steps, <var>transaction</var>,
|
|
the dynamic methods passed to these steps, the body
|
|
passed to these steps, and the content type passed to
|
|
these steps.
|
|
</li>
|
|
<li>
|
|
If there was an error while capturing, then perform the
|
|
following sub-steps and skip the remaining steps:
|
|
<ol>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error of the previous step.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
<li>
|
|
Switch to the <a class="externalDFN">newest application cache</a>
|
|
in this <a class="externalDFN">application cache group</a>.
|
|
</li>
|
|
</ol>
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">uri</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">identifying the resource to <a title="captured" href="#event-captured" class="internalDFN">capture</a></td></tr><tr><td class="prmName">body</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">entity body for the resource</td></tr><tr><td class="prmName">contentType</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">The MIME type of the entity body</td></tr><tr><td class="prmName">dynamicMethods</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">
|
|
The <a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a> that are applicable to the identified
|
|
resource. This parameter is a comma separated list of protocol
|
|
methods that can be intercepted for local processing. An empty
|
|
string is allowed for this parameter.
|
|
</td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd><dt id="widl-ApplicationCacheRequest-offlineTransaction"><code>offlineTransaction</code></dt><dd>
|
|
When this method is called, the user agent returns immediately
|
|
with a new <a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called
|
|
<var>result</var> and asynchronously performs the following steps:
|
|
<ol>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-create-a-cache-transaction" class="internalDFN">create a cache transaction</a> with
|
|
this <a class="externalDFN">application cache group</a> of this
|
|
object and a set off-line flag.
|
|
</li>
|
|
<li>
|
|
If there was an error while starting a <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>,
|
|
then perform the following sub-steps and skip the remaining steps:
|
|
<ol>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error of the previous step.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
Call the returned <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> as
|
|
<var>transaction</var>.
|
|
</li>
|
|
<li>
|
|
Let <var>txn</var> be a new
|
|
<a href="#idl-def-OfflineTransactionRequest" class="idlType"><code>OfflineTransactionRequest</code></a> object for
|
|
<var>transaction</var>.
|
|
</li>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-result"><code>result</code></a>
|
|
to be <var>txn</var>.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
<div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd><dt id="widl-ApplicationCacheRequest-openModifiedItemCursor"><code>openModifiedItemCursor</code></dt><dd>
|
|
When this method is called, the user agent performs the
|
|
steps to <a href="#dfn-create-a-cache-cursor" class="internalDFN">create a cache cursor</a> with
|
|
this <a class="externalDFN">application cache</a> and the
|
|
version passed to these steps, and returns the
|
|
result of those steps.
|
|
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">version</td><td class="prmType"><code><a>long</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"><a title="version" href="#dfn-version" class="internalDFN">Version</a> of this
|
|
<a href="#dfn-application-cache" class="internalDFN">application cache</a> since which modifications are sought.
|
|
A value <code>0</code> indicates that every modification since
|
|
the first <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> of this
|
|
<a href="#dfn-application-cache" class="internalDFN">application cache</a> is sought.</td></tr></table><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a>DOMException</a></td><td class="excDesc">
|
|
The method must raise an
|
|
<a class="externalDFN"><code>INVALID_STATE_ERR</code></a> if
|
|
the version passed to these steps is not less than the
|
|
<a href="#dfn-version" class="internalDFN">version</a> of this <a href="#dfn-application-cache" class="internalDFN">application cache</a>.
|
|
</td></tr></table><div><em>Return type: </em><code><a href="#idl-def-CacheCursorRequest" class="idlType"><code>CacheCursorRequest</code></a></code></div></dd><dt id="widl-ApplicationCacheRequest-setOutbox"><code>setOutbox</code></dt><dd>
|
|
Set the
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">uri</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">identifying the resource to use as the URL for processing items in
|
|
the outbox of the application using this
|
|
<a class="externalDFN">application cache</a></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd><dt id="widl-ApplicationCacheRequest-transaction"><code>transaction</code></dt><dd>
|
|
When this method is called, the user agent returns immediately
|
|
with a new <a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called
|
|
<var>result</var> and asynchronously performs the following steps:
|
|
<ol>
|
|
<li>
|
|
If this <a class="externalDFN">application cache group</a>
|
|
has a <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> whose <a href="#dfn-commit-status" class="internalDFN">commit status</a>
|
|
is <var>pending</var>, then choose from the following:
|
|
<dl class="switch">
|
|
<dt>If the <var>restart</var> flag
|
|
was passed to these steps and it is set</dt>
|
|
<dd>Let <var>transaction</var> be that
|
|
<a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>.</dd>
|
|
<dt>Otherwise</dt>
|
|
<dd>Perform the steps to <a href="#dfn-abort-a-cache-transaction" class="internalDFN">abort a cache transaction</a>
|
|
with that <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>.</dd>
|
|
</dl>
|
|
</li>
|
|
<li>
|
|
If <var>transaction</var> is not set, then perform the
|
|
following sub-steps:
|
|
<ol>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-create-a-cache-transaction" class="internalDFN">create a cache transaction</a> with
|
|
this <a class="externalDFN">application cache group</a> and
|
|
an unset off-line flag.
|
|
</li>
|
|
<li>
|
|
If there was an error while starting a <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>,
|
|
then perform the following sub-steps and skip the remaining steps:
|
|
<ol>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error of the previous step.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
Call the returned <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a> as
|
|
<var>transaction</var>.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
Let <var>txn</var> be a new
|
|
<a href="#idl-def-OnlineTransactionRequest" class="idlType"><code>OnlineTransactionRequest</code></a> object for
|
|
<var>transaction</var>.
|
|
</li>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-result"><code>result</code></a>
|
|
to be <var>txn</var>.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">restart</td><td class="prmType"><code><a>boolean</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">This defaults to false. This flag specifies whether to continue a
|
|
previously abandoned <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>.
|
|
</td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd></dl></div>
|
|
|
|
<p>
|
|
When the user agent is required to <dfn id="dfn-create-a-cache-cursor">create a cache cursor</dfn>,
|
|
given the <a class="externalDFN">application cache</a> and the
|
|
low watermark version, the user agent must return a new
|
|
<a href="#idl-def-CacheCursorRequest" class="idlType"><code>CacheCursorRequest</code></a> object, called <var>result</var>
|
|
and asynchronously perform the following steps:
|
|
</p>
|
|
|
|
<ol>
|
|
<li>
|
|
Let <var>additions</var> be a list of entities with their URIs and
|
|
let <var>removals</var> be a list of URIs.
|
|
</li>
|
|
<li>
|
|
Let <var>cache</var> be the <a class="externalDFN">application cache</a>
|
|
passed to these steps.
|
|
</li>
|
|
<li>
|
|
For each <a class="externalDFN">application cache</a> belonging to
|
|
<var>cache</var>'s <a class="externalDFN">application cache group</a>,
|
|
starting from <var>cache</var>'s <a href="#dfn-version" class="internalDFN">version</a> down to
|
|
<var>low watermark version</var>, perform the following sub-steps:
|
|
<ol>
|
|
<li>
|
|
Let <var>old cache</var> be the
|
|
<a class="externalDFN">application cache</a>.
|
|
</li>
|
|
<li>
|
|
Let <var>old version</var> be <var>old cache</var>'s <a href="#dfn-version" class="internalDFN">version</a>.
|
|
</li>
|
|
<li>
|
|
For the entity <var>entity</var> of each <a href="#dfn-managed" class="internalDFN">managed</a> resource of
|
|
<var>old cache</var> that was added in the <var>old version</var>, perform
|
|
the following steps:
|
|
<ol>
|
|
<li>
|
|
Let <var>id</var> be the URI of the <a href="#dfn-managed" class="internalDFN">managed</a> resource.
|
|
</li>
|
|
<li>
|
|
If neither <var>additions</var> nor <var>removals</var>
|
|
already includes <var>id</var>, then add <var>id</var>
|
|
with <var>entity</var> to <var>additions</var>.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
For each <a href="#dfn-managed" class="internalDFN">managed</a> resource of <var>old cache</var> that was
|
|
removed in the <var>old version</var>, perform the following steps:
|
|
<ol>
|
|
<li>
|
|
Let <var>id</var> be the URI of the <a href="#dfn-managed" class="internalDFN">managed</a> resource.
|
|
</li>
|
|
<li>
|
|
If neither <var>additions</var> nor <var>removals</var>
|
|
already includes <var>id</var>, then add <var>id</var>
|
|
to <var>removals</var>.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
Prepare a list of items by appending <var>removals</var> to
|
|
<var>additions</var> and set that list as <var>cursor</var>'s
|
|
<var>item list</var>.
|
|
</li>
|
|
<li>
|
|
Set <var>cursor</var>'s current position to the first item in
|
|
<var>item list</var>.
|
|
</li>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-result"><code>result</code></a>
|
|
to the item at <var>cursor</var>'s current position in
|
|
<var>item list</var>.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-CacheCursorRequest">interface <span class="idlInterfaceID">CacheCursorRequest</span> : <span class="idlSuperclass"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> {
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-CacheCursorRequest-continue">continue</a></span> ();</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="methods-2">Methods</h5><dl class="methods"><dt id="widl-CacheCursorRequest-continue"><code>continue</code></dt><dd>
|
|
<ol>
|
|
<li>
|
|
If there are no more items past this object's current position,
|
|
in <var>item list</var>, then skip the remaining steps and
|
|
perform the following sub-steps:
|
|
<ol>
|
|
<li>
|
|
Set <a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be <code>0</code>.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
If there is another item past this object's current position,
|
|
in <var>item list</var>, then move this object's current position
|
|
to the next in <var>item list</var>.
|
|
</li>
|
|
<li>
|
|
Set <a href="#widl-AppCacheRequest-result"><code>result</code></a>
|
|
to the item at <var>cursor</var>'s current position in
|
|
<var>item list</var>.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at this object with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface
|
|
</li>
|
|
</ol>
|
|
<div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-CacheTransactionRequest">interface <span class="idlInterfaceID">CacheTransactionRequest</span> {
|
|
<span class="idlAttribute"> attribute <span class="idlAttrType"><a>Function</a></span> <span class="idlAttrName"><a href="#widl-CacheTransactionRequest-oncaptured">oncaptured</a></span>;</span>
|
|
<span class="idlAttribute"> attribute <span class="idlAttrType"><a>Function</a></span> <span class="idlAttrName"><a href="#widl-CacheTransactionRequest-onreleased">onreleased</a></span>;</span>
|
|
<span class="idlAttribute"> attribute <span class="idlAttrType"><a>Function</a></span> <span class="idlAttrName"><a href="#widl-CacheTransactionRequest-onready">onready</a></span>;</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-CacheTransactionRequest-resetPendingUpdates">resetPendingUpdates</a></span> ();</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-CacheTransactionRequest-incrementPendingUpdates">incrementPendingUpdates</a></span> ();</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-CacheTransactionRequest-decrementPendingUpdates">decrementPendingUpdates</a></span> ();</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-CacheTransactionRequest-getItem">getItem</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">uri</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-CacheTransactionRequest-release">release</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">uri</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-CacheTransactionRequest-abort">abort</a></span> ();</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-CacheTransactionRequest-commit">commit</a></span> ();</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="attributes-3">Attributes</h5><dl class="attributes"><dt id="widl-CacheTransactionRequest-oncaptured"><code>oncaptured</code> of type <span class="idlAttrType"><a>Function</a></span></dt><dd>The <a class="externalDFN">event handler</a> for the
|
|
<a href="#event-captured"><code>captured</code></a>
|
|
event<div><em>No exceptions.</em></div></dd><dt id="widl-CacheTransactionRequest-onready"><code>onready</code> of type <span class="idlAttrType"><a>Function</a></span></dt><dd>The <a class="externalDFN">event handler</a> for the
|
|
<a href="#event-ready"><code>ready</code></a>
|
|
event<div><em>No exceptions.</em></div></dd><dt id="widl-CacheTransactionRequest-onreleased"><code>onreleased</code> of type <span class="idlAttrType"><a>Function</a></span></dt><dd>The <a class="externalDFN">event handler</a> for the
|
|
<a href="#event-released"><code>released</code></a>
|
|
event<div><em>No exceptions.</em></div></dd></dl></div><div class="section"><h5 id="methods-3">Methods</h5><dl class="methods"><dt id="widl-CacheTransactionRequest-abort"><code>abort</code></dt><dd>
|
|
When called, this method must immediately return with a new
|
|
<a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called <var>result</var> and
|
|
asynchronously perform the following steps:
|
|
<ol>
|
|
<li>
|
|
Execute the steps to <a href="#dfn-abort-a-cache-transaction" class="internalDFN">abort a cache transaction</a> with the
|
|
this <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>.
|
|
</li>
|
|
<li>
|
|
If the steps raised an error,
|
|
then skip the remaining steps and perform the following sub-steps:
|
|
<ol>
|
|
<li>
|
|
Set <a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error set in the above steps.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at this object with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
<div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd><dt id="widl-CacheTransactionRequest-commit"><code>commit</code></dt><dd>
|
|
When called, this method must immediately return with a new
|
|
<a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called <var>result</var> and
|
|
asynchronously perform the following steps:
|
|
<ol>
|
|
<li>
|
|
Execute the steps to <a href="#dfn-commit-a-cache-transaction" class="internalDFN">commit a cache transaction</a> with the
|
|
this <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>.
|
|
</li>
|
|
<li>
|
|
If the steps raised an error,
|
|
then skip the remaining steps and perform the following sub-steps:
|
|
<ol>
|
|
<li>
|
|
Set <a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error set in the above steps.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at this object with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
<div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd><dt id="widl-CacheTransactionRequest-decrementPendingUpdates"><code>decrementPendingUpdates</code></dt><dd>Decrement the count of pending updates for this
|
|
<a class="externalDFN">application cache</a> by <code>1</code><div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-CacheTransactionRequest-getItem"><code>getItem</code></dt><dd>
|
|
When called, this method must immediately return with a new
|
|
<a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called <var>result</var> and
|
|
asynchronously perform the following steps:
|
|
<ol>
|
|
<li>
|
|
If the resource identified by <var>uri</var> does not exist in this
|
|
<a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>'s <a class="externalDFN">application cache</a>,
|
|
then skip the remaining steps and perform the following sub-steps:
|
|
<ol>
|
|
<li>
|
|
Set <a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be <a class="externalDFN"><code>NOT_FOUND_ERR</code></a>.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
Let <var>item</var> be the entity in this
|
|
<a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>'s <a class="externalDFN">application cache</a>.
|
|
</li>
|
|
<li>
|
|
Create <var>object</var>, a new <a href="#idl-def-CacheItem" class="idlType"><code>CacheItem</code></a>
|
|
object with the associated <var>item</var>.
|
|
</li>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-result"><code>result</code></a>
|
|
to <var>object</var>.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at this object with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">uri</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">identifying the resource</td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd><dt id="widl-CacheTransactionRequest-incrementPendingUpdates"><code>incrementPendingUpdates</code></dt><dd>Increment the count of pending updates for this
|
|
<a class="externalDFN">application cache</a> by <code>1</code><div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-CacheTransactionRequest-release"><code>release</code></dt><dd>
|
|
When called, this method must immediately return with a new
|
|
<a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called <var>result</var> and
|
|
asynchronously perform the following steps:
|
|
<ol>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-add-a-resource-to-be-released" class="internalDFN">add a resource to be released</a>
|
|
with the first argument being <var>uri</var> and
|
|
the third being this <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>.
|
|
</li>
|
|
<li>
|
|
If the steps raised an error,
|
|
then skip the remaining steps and perform the following sub-steps:
|
|
<ol>
|
|
<li>
|
|
Set <a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error set in the above steps.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at this object with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">uri</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">identifying the resource to release</td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd><dt id="widl-CacheTransactionRequest-resetPendingUpdates"><code>resetPendingUpdates</code></dt><dd>Set the count of pending updates for this
|
|
<a class="externalDFN">application cache</a> to <code>0</code><div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-OnlineTransactionRequest">interface <span class="idlInterfaceID">OnlineTransactionRequest</span> : <span class="idlSuperclass"><a href="#idl-def-CacheTransactionRequest" class="idlType"><code>CacheTransactionRequest</code></a></span> {
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-OnlineTransactionRequest-capture">capture</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">uri</span></span>, <span class="idlParam">in optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">dynamicMethods</span></span>);</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="methods-4">Methods</h5><dl class="methods"><dt id="widl-OnlineTransactionRequest-capture"><code>capture</code></dt><dd>
|
|
When called, this method must immediately return with a new
|
|
<a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called <var>result</var> and
|
|
asynchronously perform the following steps:
|
|
<ol>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-add-a-resource-to-be-captured" class="internalDFN">add a resource to be captured</a>
|
|
with the URI passed to these steps, this <a href="#dfn-cache-transaction" class="internalDFN">cache transaction</a>,
|
|
and the dynamic methods passed to these steps.
|
|
</li>
|
|
<li>
|
|
If there was an error while capturing, then perform the
|
|
following sub-steps and skip the remaining steps:
|
|
<ol>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error of the previous step.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">uri</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">identifying the resource to <a>capture</a></td></tr><tr><td class="prmName">dynamicMethods</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">
|
|
The <a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a> that are applicable to the identified
|
|
resource. This parameter is a comma separated list of protocol
|
|
methods that can be intercepted for local processing. An empty
|
|
string is allowed for this parameter.
|
|
</td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd></dl></div>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-OfflineTransactionRequest">interface <span class="idlInterfaceID">OfflineTransactionRequest</span> : <span class="idlSuperclass"><a href="#idl-def-CacheTransactionRequest" class="idlType"><code>CacheTransactionRequest</code></a></span> {
|
|
<span class="idlMethod"> <span class="idlMethType"><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></span> <span class="idlMethName"><a href="#widl-OfflineTransactionRequest-capture">capture</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">uri</span></span>, <span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">body</span></span>, <span class="idlParam">in optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">contentType</span></span>, <span class="idlParam">in optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">dynamicMethods</span></span>);</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="methods-5">Methods</h5><dl class="methods"><dt id="widl-OfflineTransactionRequest-capture"><code>capture</code></dt><dd>
|
|
When called, this method must immediately return with a new
|
|
<a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a> object called <var>result</var> and
|
|
asynchronously perform the following steps:
|
|
<ol>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-add-a-resource-to-be-captured" class="internalDFN">add a resource to be captured</a>
|
|
with the URI passed to these steps, <var>transaction</var>,
|
|
the dynamic methods passed to these steps, the body
|
|
passed to these steps, and the content type passed to
|
|
these steps.
|
|
</li>
|
|
<li>
|
|
If there was an error while capturing, then perform the
|
|
following sub-steps and skip the remaining steps:
|
|
<ol>
|
|
<li>
|
|
Set <var>result</var>'s
|
|
<a href="#widl-AppCacheRequest-error"><code>error</code></a>
|
|
to be the error of the previous step.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-error internalDFN" href="#event-error"><code>error</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to fire an event
|
|
at <var>result</var> with the name
|
|
<a class="#event-success internalDFN" href="#event-success"><code>success</code></a>, which
|
|
does not bubble, is not cancelable, and which uses the
|
|
<a class="externalDFN"><code>Event</code></a> interface.
|
|
</li>
|
|
</ol>
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">uri</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">identifying the resource to <a>capture</a></td></tr><tr><td class="prmName">body</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">entity body for the resource</td></tr><tr><td class="prmName">contentType</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">The MIME type of the entity body</td></tr><tr><td class="prmName">dynamicMethods</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">
|
|
The <a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a> that are applicable to the identified
|
|
resource. This parameter is a comma separated list of protocol
|
|
methods that can be intercepted for local processing. An empty
|
|
string is allowed for this parameter.
|
|
</td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-AppCacheRequest" class="idlType"><code>AppCacheRequest</code></a></code></div></dd></dl></div> <!--
|
|
</section>
|
|
|
|
<section id="sync-datacache-interface" class="section">
|
|
<h4>Synchronous Data Cache API</h4>
|
|
|
|
<dl class="idl" title="interface CacheItemCursor">
|
|
<dt>readonly attribute CacheItem item</dt>
|
|
<dd></dd>
|
|
<dt>bool continue()</dt>
|
|
<dd></dd>
|
|
</dl>
|
|
|
|
<dl class="idl" title="interface ApplicationCache2Sync : interface ApplicationCache2">
|
|
<dt>void immediate()</dt>
|
|
<dd>
|
|
When this method is called, the user agent creates a new
|
|
<a>cache transaction</a>, and performs the steps to
|
|
<a>add a resource to be captured</a> in that <a>cache transaction</a>,
|
|
and when the identified resource is <a title="capture">captured</a>,
|
|
performs the steps to <a>activate updates</a> for this
|
|
<a class="externalDFN">application cache group</a>.
|
|
<dl class="parameters">
|
|
<dt>DOMString uri</dt>
|
|
<dd>identifying the resource to <a>capture</a></dd>
|
|
<dt>optional DOMString dynamicMethods</dt>
|
|
<dd>
|
|
The <a>dynamic methods</a> that are applicable to the identified
|
|
resource. This parameter is a comma separated list of protocol
|
|
methods that can be intercepted for local processing. An empty
|
|
string is allowed for this parameter.
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt>OnlineTransaction transaction()</dt>
|
|
<dd>
|
|
<p>
|
|
This method must perform the following steps:
|
|
</p>
|
|
<ol>
|
|
<li>
|
|
Execute the steps to <a>create a cache transaction</a> with the
|
|
first argument being the
|
|
<a class="externalDFN">application cache group</a> of this
|
|
object and the second argument being false.
|
|
</li>
|
|
<li>
|
|
Let <var>result</var> be a new <a><code>CacheTransaction</code></a>
|
|
object for the <var>transaction</var> returned from the previous step.
|
|
</li>
|
|
<li>Return <var>result</var>.</li>
|
|
</ol>
|
|
<dl class="parameters">
|
|
<dt>optional boolean restart</dt>
|
|
<dd>This defaults to false. This flag specifies whether to continue a
|
|
previously abandoned <a>cache transaction</a>.</dt>
|
|
</dl>
|
|
</dd>
|
|
<dt>OfflineTransaction offlineTransaction()</dt>
|
|
<dd>
|
|
This method takes one or two arguments - a <var>transaction
|
|
callback</var> and optionally an <var>error callback</var>.
|
|
When called, this method must immediately return and asynchronously
|
|
perform the following steps:
|
|
<ol>
|
|
<li>
|
|
Execute the steps to <a>create a cache transaction</a> with the
|
|
first argument being the
|
|
<a class="externalDFN">application cache group</a> of this <a><code>DataCache</code></a>
|
|
object and the second argument being <code>true</code>.
|
|
</li>
|
|
<li>
|
|
Let <var>result</var> be a new <a><code>CacheTransaction</code></a>
|
|
object for the <var>transaction</var> returned from the previous step.
|
|
</li>
|
|
<li>
|
|
If <var>transaction callback</var> is not null,
|
|
<a class="externalDFN">queue a task</a> to invoke the
|
|
<var>transaction callback</var>
|
|
with the aforementioned <a><code>CacheTransaction</code></a>
|
|
object as its only argument, and wait for that task to be run.
|
|
</li>
|
|
<li>
|
|
If <var>transaction callback</var> raised an exception, jump to
|
|
the last step.
|
|
</li>
|
|
<li>
|
|
End these steps. The next step is only used when something goes wrong.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to invoke the <var>error callback</var>,
|
|
if it is not null.
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
<dt>void forEachModificationSince()</dt>
|
|
<dd>
|
|
<dl class="parameters">
|
|
<dt>long version</dt>
|
|
<dd></dd>
|
|
<dt>ItemCallback callback</dt>
|
|
<dd></dd>
|
|
</dl>
|
|
This method takes one to three parameters - <var>low watermark version</var> and
|
|
<var>item callback</var>, and an optional <var> success callback</var>. When
|
|
called, this method must immediately return and asynchronously perform the
|
|
following steps:
|
|
<ol>
|
|
<li>
|
|
Let <var>additions</var> be a list of entities with their URIs and
|
|
let <var>removals</var> be a list of URIs.
|
|
</li>
|
|
<li>
|
|
Let <var>cache</var> be the <a class="externalDFN">application cache</a>
|
|
represented by this object.
|
|
</li>
|
|
<li>
|
|
For each <a class="externalDFN">application cache</a> belonging to
|
|
<var>cache</var>'s <a class="externalDFN">application cache group</a>,
|
|
starting from <var>cache</var>'s
|
|
<a>version</a> down to <var>low watermark version</var>,
|
|
perform the following sub-steps:
|
|
<ol>
|
|
<li>
|
|
Let <var>old cache</var> be the
|
|
<a class="externalDFN">application cache</a>.
|
|
</li>
|
|
<li>
|
|
Let <var>old version</var> be <var>old cache</var>'s <a>version</a>.
|
|
</li>
|
|
<li>
|
|
For the entity <var>entity</var> of each <a>managed</a> resource of
|
|
<var>old cache</var> that was added in the <var>old version</var>, perform
|
|
the following steps:
|
|
<ol>
|
|
<li>
|
|
Let <var>id</var> be the URI of the <a>managed</a> resource.
|
|
</li>
|
|
<li>
|
|
If neither <var>additions</var> nor <var>removals</var>
|
|
already includes <var>id</var>, then add <var>id</var>
|
|
with <var>entity</var> to <var>additions</var>.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
For each <a>managed</a> resource of <var>old cache</var> that was
|
|
removed in the <var>old version</var>, perform the following steps:
|
|
<ol>
|
|
<li>
|
|
Let <var>id</var> be the URI of the <a>managed</a> resource.
|
|
</li>
|
|
<li>
|
|
If neither <var>additions</var> nor <var>removals</var>
|
|
already includes <var>id</var>, then add <var>id</var>
|
|
to <var>removals</var>.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
If <var>item callback</var> is not null, then for each item
|
|
<var>item</var> in <var>additions</var>, perform the following steps:
|
|
<ol>
|
|
<li>
|
|
For each item <var>item</var> in <var>additions</var>,
|
|
<a class="externalDFN">queue a task</a> to invoke the
|
|
<var>item callback</var> with <var>item</var>.
|
|
</li>
|
|
<li>
|
|
For each item <var>item</var> in <var>removals</var>,
|
|
<a class="externalDFN">queue a task</a> to invoke the
|
|
<var>item callback</var> with <var>item</var>.
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
If <var>success callback</var> is not null, then
|
|
<a class="externalDFN">queue a task</a> to invoke the <var>success callback</var>
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
</dl>
|
|
</section>
|
|
|
|
<section id="transaction-interface" class="section">
|
|
<h4>Transaction API</h4>
|
|
|
|
<dl class="idl" title="interface CacheTransaction">
|
|
<dt>void resetPendingUpdates()</dt>
|
|
<dd></dd>
|
|
<dt>void incrementPendingUpdates()</dt>
|
|
<dd></dd>
|
|
<dt>void decrementPendingUpdates()</dt>
|
|
<dd></dd>
|
|
<dt>CacheItem getItem(in DOMString uri)</dt>
|
|
<dd>
|
|
When called, this method must immediately return and
|
|
asynchronously perform the following steps:
|
|
<ol>
|
|
<li>
|
|
If the resource identified by <var>uri</var> does not exist in this
|
|
<a><code>CacheTransaction</code></a> object's associated
|
|
<a class="externalDFN">application cache</a>, then the method must raise the
|
|
<code>NOT_FOUND_ERR</code> exception and terminate these steps.
|
|
</li>
|
|
<li>
|
|
Let <var>item</var> be the entity in this
|
|
<a><code>CacheTransaction</code></a> object's associated
|
|
<a class="externalDFN">application cache</a>.
|
|
</li>
|
|
<li>
|
|
Create <var>object</var>, a new <a><code>CacheItem</code></a>
|
|
object with the associated <var>item</var>.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Queue a task</a> to invoke <var>item callback</var> with the
|
|
aforementioned <a><code>CacheItem</code></a> <var>object</var>
|
|
as its only argument.
|
|
</li>
|
|
</ol>
|
|
<dl class="parameters">
|
|
<dt>DOMString uri</dt>
|
|
<dd>identifying the resource</dd>
|
|
<dt>ItemCallback callback</dt>
|
|
<dd>Callback to invoke with the cached resource information</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt>void release(in DOMString uri)</dt>
|
|
<dd>
|
|
When called, this method must immediately return and asynchronously
|
|
perform the steps to <a>add a resource to be released</a>
|
|
with the first argument being <var>uri</var>, second being the
|
|
<a class="externalDFN">active document</a> of the
|
|
<a class="externalDFN">browsing context</a> of the
|
|
<code>Window</code> or <code>WorkerGlobalScope</code> object of the
|
|
<code>Worker</code>,
|
|
and the third being this <a><code>CacheTransaction</code></a>
|
|
object's associated <a>cache transaction</a>.
|
|
<dl class="parameters">
|
|
<dt>DOMString uri</dt>
|
|
<dd>identifying the resource to release</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt>void commit()</dt>
|
|
<dd>
|
|
When called, this method must immediately return and asynchronously
|
|
perform the following steps:
|
|
<ol>
|
|
<li>
|
|
Execute the steps to <a>commit a cache transaction</a> with the
|
|
first argument being this <a><code>CacheTransaction</code></a>
|
|
object's associated <a>cache transaction</a>,
|
|
and the second being the current <code>Window</code> or
|
|
<code>Worker</code> object.
|
|
</li>
|
|
<li>
|
|
If <a href="#widl-CacheTransaction-oncommitted"><code>oncommitted</code></a>
|
|
attribute on this <a><code>CacheTransaction</code></a> object is not null,
|
|
<a class="externalDFN">queue a task</a> to invoke the function identified by
|
|
<a href="#widl-CacheTransaction-oncommitted"><code>oncommitted</code></a> .
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
</dl>
|
|
|
|
<dl class="idl" title="interface OnlineTransaction : CacheTransaction">
|
|
<dt>void capture()</dt>
|
|
<dd>
|
|
When called, this
|
|
method must immediately return and asynchronously perform the steps
|
|
to <a>add a resource to be captured</a> with the first argument being
|
|
<var>uri</var>, second being the <a class="externalDFN">active document</a>
|
|
of the <a class="externalDFN">browsing context</a> of the
|
|
<code>Window</code> or <code>WorkerGlobalScope</code> object of the
|
|
<code>Worker</code>, the third being this
|
|
<a><code>CacheTransaction</code></a> object's associated
|
|
<a>cache transaction</a>,
|
|
the fourth being <var>dynamic methods</var>.
|
|
<dl class="parameters">
|
|
<dt>DOMString uri</dt>
|
|
<dd>identifying the resource to <a>capture</a></dd>
|
|
<dt>optional DOMString dynamicMethods</dt>
|
|
<dd>
|
|
The <a>dynamic methods</a> that are applicable to the identified
|
|
resource. This parameter is a comma separated list of protocol
|
|
methods that can be intercepted for local processing. An empty
|
|
string is allowed for this parameter.
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt>void abort()</dt>
|
|
<dd>
|
|
When called, this method must immediately return and asynchronously
|
|
perform the steps to <a>abort a cache transaction</a> with the first argument
|
|
being this <a><code>CacheTransaction</code></a> object's associated
|
|
<a>cache transaction</a>, and the second being the
|
|
<code>window</code> or <code>worker</code> object.
|
|
</dd>
|
|
</dl>
|
|
|
|
<dl class="idl" title="interface OfflineTransaction : CacheTransaction">
|
|
<dt>void capture()</dt>
|
|
<dd> When called, this
|
|
method must immediately return and asynchronously perform the steps
|
|
to <a>add a resource to be captured</a> with the first argument being
|
|
<var>uri</var>, second being the
|
|
<a class="externalDFN">active document</a> of the
|
|
<a class="externalDFN">browsing context</a> of the
|
|
<code>window</code> or <code>WorkerGlobalScope</code> object of the
|
|
<code>worker</code>,
|
|
the third being this <a><code>CacheTransaction</code></a> object's
|
|
associated <a>cache transaction</a>, the fourth being
|
|
<var>dynamic methods</var>, the fifth being <var>entity body</var>,
|
|
and the sixth being <var>content type</var>.
|
|
<dl class="parameters">
|
|
<dt>DOMString uri</dt>
|
|
<dd>identifying the resource to <a>capture</a></dd>
|
|
<dt>DOMString body</dt>
|
|
<dd>entity body for the resource</dd>
|
|
<dt>optional DOMString contentType</dt>
|
|
<dd>The MIME type of the entity body</dd>
|
|
<dt>optional DOMString dynamicMethods</dt>
|
|
<dd>
|
|
The <a>dynamic methods</a> that are applicable to the identified
|
|
resource. This parameter is a comma separated list of protocol
|
|
methods that can be intercepted for local processing. An empty
|
|
string is allowed for this parameter.
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
</dl-->
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-CacheItem">interface <span class="idlInterfaceID">CacheItem</span> {
|
|
<span class="idlConst"> const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-CacheItem-UNCACHED">UNCACHED</a></span> = <span class="idlConstValue">0</span>;</span>
|
|
<span class="idlConst"> const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-CacheItem-FETCHING">FETCHING</a></span> = <span class="idlConstValue">1</span>;</span>
|
|
<span class="idlConst"> const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-CacheItem-CACHED">CACHED</a></span> = <span class="idlConstValue">2</span>;</span>
|
|
<span class="idlConst"> const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-CacheItem-GONE">GONE</a></span> = <span class="idlConstValue">3</span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>unsigned short</a></span> <span class="idlAttrName"><a href="#widl-CacheItem-readyState">readyState</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>Blob</a></span> <span class="idlAttrName"><a href="#widl-CacheItem-body">body</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>DOMStringList</a></span> <span class="idlAttrName"><a href="#widl-CacheItem-dynamicMethods">dynamicMethods</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>any</a></span> <span class="idlAttrName"><a href="#widl-CacheItem-headers">headers</a></span>;</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="attributes-4">Attributes</h5><dl class="attributes"><dt id="widl-CacheItem-body"><code>body</code> of type <span class="idlAttrType"><a>Blob</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the entity body, if any, as a
|
|
<a class="externalDFN"><code>Blob</code></a> object, of the <a href="#dfn-managed" class="internalDFN">managed</a>
|
|
resource associated with this <a href="#idl-def-CacheItem" class="idlType"><code>CacheItem</code></a> object.
|
|
<div><em>No exceptions.</em></div></dd><dt id="widl-CacheItem-dynamicMethods"><code>dynamicMethods</code> of type <span class="idlAttrType"><a>DOMStringList</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the list of protocol methods,
|
|
if any, of the <a href="#dfn-managed" class="internalDFN">managed</a> resource associated with this
|
|
<a href="#idl-def-CacheItem" class="idlType"><code>CacheItem</code></a> object.
|
|
<div><em>No exceptions.</em></div></dd><dt id="widl-CacheItem-headers"><code>headers</code> of type <span class="idlAttrType"><a>any</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the headers as a native ordered
|
|
dictionary data type from the <a href="#dfn-managed" class="internalDFN">managed</a> resource associated
|
|
with this <a href="#idl-def-CacheItem" class="idlType"><code>CacheItem</code></a> object. In the ECMAScript
|
|
binding, this must be <code>Object</code>. Each header must have
|
|
one property (or dictionary
|
|
entry), with those properties enumerating in the order that the headers
|
|
were recorded in the <a href="#dfn-managed" class="internalDFN">managed</a> resource. Each property must
|
|
have the name of the header and its value as recorded in the
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource.
|
|
<div><em>No exceptions.</em></div></dd><dt id="widl-CacheItem-readyState"><code>readyState</code> of type <span class="idlAttrType"><a>unsigned short</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the current state of the
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource.
|
|
<div><em>No exceptions.</em></div></dd></dl></div><div class="section"><h5 id="constants-1">Constants</h5><dl class="constants"><dt id="widl-CacheItem-CACHED"><code>CACHED</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>
|
|
This <a href="#idl-def-CacheItem" class="idlType"><code>CacheItem</code></a> object is associated with a
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource which has been cached.
|
|
</dd><dt id="widl-CacheItem-FETCHING"><code>FETCHING</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>
|
|
This <a href="#idl-def-CacheItem" class="idlType"><code>CacheItem</code></a> object is associated with a
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource which is currently being fetched.
|
|
There is no value available in
|
|
<a href="#widl-CacheItem-body"><code>body</code></a>
|
|
or <a href="#widl-CacheItem-headers"><code>headers</code></a>.
|
|
</dd><dt id="widl-CacheItem-GONE"><code>GONE</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>
|
|
This <a href="#idl-def-CacheItem" class="idlType"><code>CacheItem</code></a> object is associated with a
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource which has been released. There is no
|
|
value available in
|
|
<a href="#widl-CacheItem-body"><code>body</code></a>,
|
|
<a href="#widl-CacheItem-headers"><code>headers</code></a>, or
|
|
<a href="#widl-CacheItem-dynamicMethods"><code>dynamicMethods</code></a>.
|
|
</dd><dt id="widl-CacheItem-UNCACHED"><code>UNCACHED</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>
|
|
This <a href="#idl-def-CacheItem" class="idlType"><code>CacheItem</code></a> object is associated with a
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource
|
|
which has been added for capturing but has not yet been cached.
|
|
There is no value available in <a href="#widl-CacheItem-body"><code>body</code></a>
|
|
or <a href="#widl-CacheItem-headers"><code>headers</code></a>.
|
|
</dd></dl></div>
|
|
</div>
|
|
|
|
<div id="events-and-error" class="section">
|
|
<h4><span class="secno">4.2.9 </span>The <code>CacheEvent</code> Interface</h4>
|
|
<p>
|
|
The <a class="externalDFN">task source</a> for this task is the
|
|
<dfn id="dfn-networking-task-source">networking task source</dfn>.
|
|
</p>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-CacheEvent">interface <span class="idlInterfaceID">CacheEvent</span> : <span class="idlSuperclass"><a>Event</a></span> {
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>DOMString</a></span> <span class="idlAttrName"><a href="#widl-CacheEvent-uri">uri</a></span>;</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-CacheEvent-initCacheEvent">initCacheEvent</a></span> (<span class="idlParam">in optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">uri</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-CacheEvent-initCacheEventNS">initCacheEventNS</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">namespaceURI</span></span>, <span class="idlParam">in optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">uri</span></span>);</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="attributes-5">Attributes</h5><dl class="attributes"><dt id="widl-CacheEvent-uri"><code>uri</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>This attribute, on getting, must return the URI of the
|
|
<a href="#dfn-managed" class="internalDFN">managed</a> resource for which this event is fired.
|
|
<div><em>No exceptions.</em></div></dd></dl></div><div class="section"><h5 id="methods-6">Methods</h5><dl class="methods"><dt id="widl-CacheEvent-initCacheEvent"><code>initCacheEvent</code></dt><dd>These methods must initialize the event in a manner analogous to the
|
|
similarly named methods in the DOM Events interfaces.
|
|
[<cite><a class="bibref" rel="biblioentry" href="#bib-DOM-LEVEL-3-EVENTS">DOM-LEVEL-3-EVENTS</a></cite>]
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">uri</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-CacheEvent-initCacheEventNS"><code>initCacheEventNS</code></dt><dd>These methods must initialize the event in a manner analogous to the
|
|
similarly named methods in the DOM Events interfaces.
|
|
[<cite><a class="bibref" rel="biblioentry" href="#bib-DOM-LEVEL-3-EVENTS">DOM-LEVEL-3-EVENTS</a></cite>]
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">namespaceURI</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">uri</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
|
|
<p>
|
|
The following are the <a href="#dfn-event-handler" class="internalDFN">event handler</a>s (and their corresponding
|
|
<a href="#dfn-event-handler-event-type" class="internalDFN">event handler event type</a>s) that must be supported, as IDL
|
|
attributes, by objects implementing the
|
|
<a><code>CacheTransaction</code></a> interface and
|
|
<a href="#idl-def-CacheTransactionRequest" class="idlType"><code>CacheTransactionRequest</code></a> interface:
|
|
</p>
|
|
|
|
<table>
|
|
<thead><tr>
|
|
<th><a class="externalDFN">Event handler</a> </th>
|
|
<th><a class="externalDFN">Event handler event type</a></th>
|
|
</tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><dfn id="dfn-onready"><code>onready</code></dfn> </td>
|
|
<td><a href="#event-ready"><code>ready</code></a></td>
|
|
</tr>
|
|
<tr>
|
|
<td><dfn id="dfn-oncaptured"><code>oncaptured</code></dfn> </td>
|
|
<td><a href="#event-captured"><code>captured</code></a></td>
|
|
</tr>
|
|
<tr>
|
|
<td><dfn id="dfn-onreleased"><code>onreleased</code></dfn> </td>
|
|
<td><a href="#event-released"><code>released</code></a></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="local-server" class="section">
|
|
<h3><span class="secno">4.3 </span>Programmable HTTP Serving</h3>
|
|
|
|
<p>
|
|
An <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a> is an application script that generates
|
|
<a href="#dfn-dynamic" class="internalDFN">dynamic</a> responses to resource requests without making those
|
|
requests to the origin server.
|
|
</p>
|
|
|
|
<p>
|
|
An <dfn id="dfn-embedded-local-server">embedded local server</dfn> consists of an
|
|
<dfn id="dfn-interceptor">interceptor</dfn> function and zero or one <dfn id="dfn-reviewer">reviewer</dfn> function.
|
|
</p>
|
|
|
|
<p>
|
|
An <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a>
|
|
serves requests to resources in its <dfn id="dfn-interception-namespace">interception namespace</dfn>.
|
|
</p>
|
|
|
|
<p>
|
|
A <a class="externalDFN">cache host</a> can be associated with
|
|
zero or more <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a>s.
|
|
</p>
|
|
|
|
<p>
|
|
An resource request issued in a <a class="externalDFN">cache host</a> can
|
|
be an <dfn id="dfn-interceptible-request">interceptible request</dfn> if the resource is in the
|
|
<a href="#dfn-interception-namespace" class="internalDFN">interception namespace</a> of an <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a>
|
|
registered in the <a class="externalDFN">browsing context</a> of the
|
|
<a class="externalDFN">cache host</a> and the resource is a
|
|
<a href="#dfn-dynamic-entry" class="internalDFN">dynamic entry</a> in the <a class="externalDFN">application cache group</a>
|
|
associated with the <a class="externalDFN">cache host</a> and the request method
|
|
is identified as one of the <a href="#dfn-dynamic-entry" class="internalDFN">dynamic entry</a>'s <a href="#dfn-dynamic-methods" class="internalDFN">dynamic methods</a> .
|
|
</p>
|
|
|
|
<p>
|
|
If an <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a>
|
|
can <a>intercept a resource request</a>, then it is called a
|
|
<dfn id="dfn-candidate-local-server">candidate local server</dfn> for that request.
|
|
</p>
|
|
|
|
<p>
|
|
Multiple <a>embedded local servers</a> can be the <a href="#dfn-candidate-local-server" class="internalDFN">candidate local server</a>
|
|
for a given resource request. If a user agent is to
|
|
<dfn id="dfn-select-an-embedded-local-server">select an embedded local server</dfn> from a list of
|
|
<a href="#dfn-candidate-local-server" class="internalDFN">candidate local server</a>s that can produce a <a href="#dfn-dynamic" class="internalDFN">dynamic</a> representation
|
|
of the requested resource, then the user agent must use the
|
|
<a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a> that has the most specific
|
|
<a href="#dfn-interception-namespace" class="internalDFN">interception namespace</a>.
|
|
</p>
|
|
<div id="request-interface" class="section">
|
|
<h4><span class="secno">4.3.1 </span>Local Server Interfaces</h4>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-NavigatorLocalServer">[<span class="extAttr">Supplemental, NoInterfaceObject</span>]
|
|
interface <span class="idlInterfaceID">NavigatorLocalServer</span> {
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-NavigatorLocalServer-registerOfflineHandler">registerOfflineHandler</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">namespace</span></span>, <span class="idlParam">in <span class="idlParamType"><a href="#idl-def-InterceptHandler" class="idlType"><code>InterceptHandler</code></a></span> <span class="idlParamName">intercept</span></span>, <span class="idlParam">in optional <span class="idlParamType"><a href="#idl-def-ReviewHandler" class="idlType"><code>ReviewHandler</code></a></span> <span class="idlParamName">review</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-NavigatorLocalServer-removeOfflineHandler">removeOfflineHandler</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">namespace</span></span>) raises (<span class="idlRaises"><a>DOMException</a></span>);</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="methods-7">Methods</h5><dl class="methods"><dt id="widl-NavigatorLocalServer-registerOfflineHandler"><code>registerOfflineHandler</code></dt><dd>
|
|
|
|
<p>
|
|
This method allows applications to register possible handlers
|
|
for particular URI namespaces. Upon being invoked, this method
|
|
should create a new <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a> called
|
|
<var>server</var> with its <a href="#dfn-interceptor" class="internalDFN">interceptor</a>
|
|
function set to <var>intercept handler</var> and its
|
|
<a href="#dfn-reviewer" class="internalDFN">reviewer</a> function set to <var>review handler</var>
|
|
and add <var>server</var> to the <a href="#dfn-cache-host" class="internalDFN">cache host</a>, which is
|
|
the <a href="#dfn-active-document" class="internalDFN">active document</a> of the <a href="#dfn-browsing-context" class="internalDFN">browsing context</a> of the
|
|
<code>window</code> containing this <code>Navigator</code> object.
|
|
If a handler already exists for the given <var>namespace</var>,
|
|
the existing <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a> is replaced with the
|
|
one created in this call.
|
|
</p>
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">namespace</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">identifying the <a href="#dfn-interception-namespace" class="internalDFN">interception namespace</a> for this
|
|
<a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a></td></tr><tr><td class="prmName">intercept</td><td class="prmType"><code><a href="#idl-def-InterceptHandler" class="idlType"><code>InterceptHandler</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">the <a href="#dfn-interceptor" class="internalDFN">interceptor</a> function of this <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a></td></tr><tr><td class="prmName">review</td><td class="prmType"><code><a href="#idl-def-ReviewHandler" class="idlType"><code>ReviewHandler</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">the <a href="#dfn-reviewer" class="internalDFN">reviewer</a> function of this <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-NavigatorLocalServer-removeOfflineHandler"><code>removeOfflineHandler</code></dt><dd>
|
|
This method removes the registered <a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a>
|
|
for the given namespace from the <a href="#dfn-cache-host" class="internalDFN">cache host</a>, which is
|
|
the <a href="#dfn-active-document" class="internalDFN">active document</a> of the <a href="#dfn-browsing-context" class="internalDFN">browsing context</a> of the
|
|
<code>window</code> containing this <code>Navigator</code> object.
|
|
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">namespace</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">identifying the <a href="#dfn-interception-namespace" class="internalDFN">interception namespace</a> for this
|
|
<a href="#dfn-embedded-local-server" class="internalDFN">embedded local server</a></td></tr></table><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a>DOMException</a></td><td class="excDesc">
|
|
The method must raise an
|
|
<a class="externalDFN"><code>NOT_FOUND_ERR</code></a> if
|
|
the version passed to these steps is not less than the
|
|
<a href="#dfn-version" class="internalDFN">version</a> of this <a href="#dfn-application-cache" class="internalDFN">application cache</a>.
|
|
</td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
|
|
|
|
<pre class="idl"><span class="idlImplements"><a>Navigator</a> implements <a href="#idl-def-NavigatorLocalServer" class="idlType"><code>NavigatorLocalServer</code></a>;</span></pre><div class="idlImplementsDesc"><p>All instances of the <code><a>Navigator</a></code> type are defined to also implement the <a href="#idl-def-NavigatorLocalServer" class="idlType"><code>NavigatorLocalServer</code></a> interface.</p></div>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-InterceptHandler">[<span class="extAttr">Callback=FunctionOnly, NoInterfaceObject</span>]
|
|
interface <span class="idlInterfaceID">InterceptHandler</span> {
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-InterceptHandler-callback">callback</a></span> (<span class="idlParam">in <span class="idlParamType"><a href="#idl-def-HttpRequest" class="idlType"><code>HttpRequest</code></a></span> <span class="idlParamName">request</span></span>, <span class="idlParam">in <span class="idlParamType"><a href="#idl-def-MutableHttpResponse" class="idlType"><code>MutableHttpResponse</code></a></span> <span class="idlParamName">response</span></span>);</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="methods-8">Methods</h5><dl class="methods"><dt id="widl-InterceptHandler-callback"><code>callback</code></dt><dd>
|
|
<p>
|
|
The user agent must invoke the <a href="#idl-def-InterceptHandler" class="idlType"><code>InterceptHandler</code></a>,
|
|
with an <a href="#idl-def-HttpRequest" class="idlType"><code>HttpRequest</code></a>
|
|
object <var>request</var> based on the application's resource request and an
|
|
<a href="#idl-def-MutableHttpResponse" class="idlType"><code>MutableHttpResponse</code></a>
|
|
object <var>response</var>. If the <a href="#widl-MutableHttpResponse-delay">
|
|
<code>delay()</code></a> method is invoked on <var>response</var>,
|
|
then when the <a href="#widl-MutableHttpResponse-send">
|
|
<code>send()</code></a> method is invoked on <var>response</var>, the
|
|
user agent <em class="rfc2119" title="must">must</em> respond to <var>request</var> with the headers, body, and
|
|
status specified in <var>response</var>.
|
|
If the <a href="#widl-MutableHttpResponse-delay">
|
|
<code>delay()</code></a> method is not invoked on <var>response</var>
|
|
in this callback, then the user agent <em class="rfc2119" title="must">must</em> respond to <var>request</var>
|
|
with the headers, body, and status, specified in <var>response</var>
|
|
when this function exits.
|
|
</p>
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">request</td><td class="prmType"><code><a href="#idl-def-HttpRequest" class="idlType"><code>HttpRequest</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">response</td><td class="prmType"><code><a href="#idl-def-MutableHttpResponse" class="idlType"><code>MutableHttpResponse</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-ReviewHandler">[<span class="extAttr">Callback=FunctionOnly, NoInterfaceObject</span>]
|
|
interface <span class="idlInterfaceID">ReviewHandler</span> {
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-ReviewHandler-callback">callback</a></span> (<span class="idlParam">in <span class="idlParamType"><a href="#idl-def-HttpRequest" class="idlType"><code>HttpRequest</code></a></span> <span class="idlParamName">request</span></span>, <span class="idlParam">in <span class="idlParamType"><a href="#idl-def-HttpResponse" class="idlType"><code>HttpResponse</code></a></span> <span class="idlParamName">response</span></span>);</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="methods-9">Methods</h5><dl class="methods"><dt id="widl-ReviewHandler-callback"><code>callback</code></dt><dd>
|
|
<p>
|
|
The user agent must invoke the <a href="#idl-def-ReviewHandler" class="idlType"><code>ReviewHandler</code></a>,
|
|
with an <a href="#idl-def-HttpRequest" class="idlType"><code>HttpRequest</code></a>
|
|
object <var>request</var> based on the application's resource request and an
|
|
<a href="#idl-def-HttpResponse" class="idlType"><code>HttpResponse</code></a>
|
|
object <var>response</var> based on the host's response to that request.
|
|
</p>
|
|
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">request</td><td class="prmType"><code><a href="#idl-def-HttpRequest" class="idlType"><code>HttpRequest</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">response</td><td class="prmType"><code><a href="#idl-def-HttpResponse" class="idlType"><code>HttpResponse</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-HttpRequest">interface <span class="idlInterfaceID">HttpRequest</span> {
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>DOMString</a></span> <span class="idlAttrName"><a href="#widl-HttpRequest-method">method</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>DOMString</a></span> <span class="idlAttrName"><a href="#widl-HttpRequest-target">target</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>DOMString</a></span> <span class="idlAttrName"><a href="#widl-HttpRequest-bodyText">bodyText</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>any</a></span> <span class="idlAttrName"><a href="#widl-HttpRequest-headers">headers</a></span>;</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="attributes-6">Attributes</h5><dl class="attributes"><dt id="widl-HttpRequest-bodyText"><code>bodyText</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
|
|
This attribute is a DOMString representing the request entity body,
|
|
which on getting, must return the result of the following steps:
|
|
<ol>
|
|
<li>
|
|
If the request entity body is null, return the empty string and
|
|
terminate these steps.
|
|
</li>
|
|
<li>
|
|
Let <var>charset</var> be the value of the
|
|
<code>charset</code> parameter of the <code>Content-Type</code>
|
|
header or <code>null</code> if there was no <code>charset</code>
|
|
parameter or if the header could not be parsed properly or was
|
|
omitted.
|
|
</li>
|
|
<li>
|
|
Let <var>mime</var> be the MIME type the <code>Content-Type</code>
|
|
header contains without any parameters or <code>null</code> if
|
|
the header could not be parsed properly or was omitted.
|
|
</li>
|
|
<li>
|
|
If <var>charset</var> is <code>null</code> and <var>mime</var>
|
|
is <code>text/xml</code>,
|
|
<code>application/xml</code>, or ends in <code>+xml</code>
|
|
use the rules set forth in the XML specifications to determine
|
|
the character encoding. Let <var>charset</var> be the
|
|
determined character encoding.
|
|
</li>
|
|
<li>
|
|
If <var>charset</var> is <code>null</code> and <var>mime</var> is
|
|
<code>application/json</code> follow the rules set forth in the
|
|
[<cite><a class="bibref" rel="biblioentry" href="#bib-RFC4627">RFC4627</a></cite>] specification to determine the character encoding.
|
|
Let <var>charset</var> be the determined character encoding.
|
|
</li>
|
|
<li>
|
|
If <var>charset</var> is <code>null</code> and <var>mime</var> is
|
|
<code>text/html</code> follow the rules set forth in the [<cite><a class="bibref" rel="biblioentry" href="#bib-HTML5">HTML5</a></cite>]
|
|
specification to determine the character encoding. Let
|
|
<var>charset</var> be the determined character encoding.
|
|
</li>
|
|
<li>
|
|
If <var>charset</var> is <code>null</code>, then let
|
|
<var>charset</var> be <code>UTF-8</code>.
|
|
</li>
|
|
<li>
|
|
Return the result of decoding the response entity body using
|
|
<var>charset</var>. Replace bytes or sequences of bytes that are
|
|
not valid accordng to the <var>charset</var> with a single
|
|
U+FFFD REPLACEMENT CHARACTER character.
|
|
</li>
|
|
</ol>
|
|
<div><em>No exceptions.</em></div></dd><dt id="widl-HttpRequest-headers"><code>headers</code> of type <span class="idlAttrType"><a>any</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the headers as a native ordered
|
|
dictionary data type from this <a href="#idl-def-HttpRequest" class="idlType"><code>HttpRequest</code></a> object.
|
|
In the JavaScript binding, this must be
|
|
<code>Object</code>. Each header must have one property (or dictionary
|
|
entry), with those properties enumerating in the order that the headers
|
|
were present in the request. Each property must have the name of the
|
|
header and its value as present in the request.
|
|
<div><em>No exceptions.</em></div></dd><dt id="widl-HttpRequest-method"><code>method</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the HTTP method,
|
|
in upper-case characters, present on this
|
|
<a href="#idl-def-HttpRequest" class="idlType"><code>HttpRequest</code></a> object.
|
|
<div><em>No exceptions.</em></div></dd><dt id="widl-HttpRequest-target"><code>target</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the URI of this
|
|
<a href="#idl-def-HttpRequest" class="idlType"><code>HttpRequest</code></a> object.
|
|
<div><em>No exceptions.</em></div></dd></dl></div>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-MutableHttpResponse">interface <span class="idlInterfaceID">MutableHttpResponse</span> {
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-MutableHttpResponse-setStatus">setStatus</a></span> (<span class="idlParam">in <span class="idlParamType"><a>unsigned short</a></span> <span class="idlParamName">code</span></span>, <span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">message</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-MutableHttpResponse-setResponseText">setResponseText</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">text</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-MutableHttpResponse-setResponseHeader">setResponseHeader</a></span> (<span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">name</span></span>, <span class="idlParam">in <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">value</span></span>);</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-MutableHttpResponse-delay">delay</a></span> ();</span>
|
|
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-MutableHttpResponse-send">send</a></span> ();</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="methods-10">Methods</h5><dl class="methods"><dt id="widl-MutableHttpResponse-delay"><code>delay</code></dt><dd>
|
|
Mark this response to be explicitly dispatched. This means that the
|
|
<a href="#idl-def-InterceptHandler" class="idlType"><code>InterceptHandler</code></a> would need to explicitly call
|
|
<a href="#widl-MutableHttpResponse-send"><code>send()</code></a>
|
|
in order to mark the response as ready for being returned to the
|
|
application.
|
|
<div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-MutableHttpResponse-send"><code>send</code></dt><dd>
|
|
Upon calling, this method must dispatch this
|
|
<a href="#idl-def-MutableHttpResponse" class="idlType"><code>MutableHttpResponse</code></a>
|
|
object. No further changes must be allowed to it.
|
|
<div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-MutableHttpResponse-setResponseHeader"><code>setResponseHeader</code></dt><dd>
|
|
This method takes two arguments - <var>name</var> and <var>value</var>
|
|
of a response header. Upon calling, this method must store the header
|
|
with <var>name</var> and <var>value</var> in this
|
|
<a href="#idl-def-MutableHttpResponse" class="idlType"><code>MutableHttpResponse</code></a>
|
|
object. If a value is already associated with this header, then
|
|
this method must append <var>value</var> to it.
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">name</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">value</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-MutableHttpResponse-setResponseText"><code>setResponseText</code></dt><dd>
|
|
This method takes a single arguments - <var>body</var> of the response entity.
|
|
Upon calling, this method must store the entity <var>body</var> in this
|
|
<a href="#idl-def-MutableHttpResponse" class="idlType"><code>MutableHttpResponse</code></a>
|
|
object, replacing any previous value.
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">text</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-MutableHttpResponse-setStatus"><code>setStatus</code></dt><dd>
|
|
This method takes two arguments - <var>code</var> and <var>message</var>
|
|
of the response status. Upon calling, this method must store the status
|
|
with <var>code</var> and <var>message</var> in this
|
|
<a href="#idl-def-MutableHttpResponse" class="idlType"><code>MutableHttpResponse</code></a>
|
|
object, replacing any previous values for both.
|
|
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">code</td><td class="prmType"><code><a>unsigned short</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">message</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
|
|
|
|
<pre class="idl"><span class="idlInterface" id="idl-def-HttpResponse">interface <span class="idlInterfaceID">HttpResponse</span> {
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>unsigned short</a></span> <span class="idlAttrName"><a href="#widl-HttpResponse-statusCode">statusCode</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>DOMString</a></span> <span class="idlAttrName"><a href="#widl-HttpResponse-statusMessage">statusMessage</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>DOMString</a></span> <span class="idlAttrName"><a href="#widl-HttpResponse-bodyText">bodyText</a></span>;</span>
|
|
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>any</a></span> <span class="idlAttrName"><a href="#widl-HttpResponse-headers">headers</a></span>;</span>
|
|
};</span>
|
|
</pre><div class="section"><h5 id="attributes-7">Attributes</h5><dl class="attributes"><dt id="widl-HttpResponse-bodyText"><code>bodyText</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
|
|
This attribute is a DOMString representing the response entity body,
|
|
which on getting, must return the result of the following steps:
|
|
<ol>
|
|
<li>
|
|
If the response entity body is null, return the empty string and
|
|
terminate these steps.
|
|
</li>
|
|
<li>
|
|
Let <var>charset</var> be the value of the
|
|
<code>charset</code> parameter of the <code>Content-Type</code>
|
|
header or <code>null</code> if there was no <code>charset</code>
|
|
parameter or if the header could not be parsed properly or was
|
|
omitted.
|
|
</li>
|
|
<li>
|
|
Let <var>mime</var> be the MIME type the <code>Content-Type</code>
|
|
header contains without any parameters or <code>null</code> if
|
|
the header could not be parsed properly or was omitted.
|
|
</li>
|
|
<li>
|
|
If <var>charset</var> is <code>null</code> and <var>mime</var>
|
|
is <code>text/xml</code>,
|
|
<code>application/xml</code>, or ends in <code>+xml</code>
|
|
use the rules set forth in the XML specifications to determine
|
|
the character encoding. Let <var>charset</var> be the
|
|
determined character encoding.
|
|
</li>
|
|
<li>
|
|
If <var>charset</var> is <code>null</code> and <var>mime</var> is
|
|
<code>application/json</code> follow the rules set forth in the
|
|
[<cite><a class="bibref" rel="biblioentry" href="#bib-RFC4627">RFC4627</a></cite>] specification to determine the character encoding.
|
|
Let <var>charset</var> be the determined character encoding.
|
|
</li>
|
|
<li>
|
|
If <var>charset</var> is <code>null</code> and <var>mime</var> is
|
|
<code>text/html</code> follow the rules set forth in the [<cite><a class="bibref" rel="biblioentry" href="#bib-HTML5">HTML5</a></cite>]
|
|
specification to determine the character encoding. Let
|
|
<var>charset</var> be the determined character encoding.
|
|
</li>
|
|
<li>
|
|
If <var>charset</var> is <code>null</code>, then let
|
|
<var>charset</var> be <code>UTF-8</code>.
|
|
</li>
|
|
<li>
|
|
Return the result of decoding the response entity body using
|
|
<var>charset</var>. Replace bytes or sequences of bytes that are
|
|
not valid accordng to the <var>charset</var> with a single
|
|
U+FFFD REPLACEMENT CHARACTER character.
|
|
</li>
|
|
</ol>
|
|
<div><em>No exceptions.</em></div></dd><dt id="widl-HttpResponse-headers"><code>headers</code> of type <span class="idlAttrType"><a>any</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the headers as a native ordered
|
|
dictionary data type from this
|
|
<a href="#idl-def-HttpResponse" class="idlType"><code>HttpResponse</code></a> object.
|
|
In the JavaScript binding, this must be
|
|
<code>Object</code>. Each header must have one property (or dictionary
|
|
entry), with those properties enumerating in the order that the headers
|
|
were present in the response. Each property must have the name of the
|
|
header and its value as present in the response.
|
|
<div><em>No exceptions.</em></div></dd><dt id="widl-HttpResponse-statusCode"><code>statusCode</code> of type <span class="idlAttrType"><a>unsigned short</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the status code of this
|
|
<a href="#idl-def-HttpResponse" class="idlType"><code>HttpResponse</code></a> object.
|
|
<div><em>No exceptions.</em></div></dd><dt id="widl-HttpResponse-statusMessage"><code>statusMessage</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
|
|
This attribute, on getting, must return the status message of this
|
|
<a href="#idl-def-HttpResponse" class="idlType"><code>HttpResponse</code></a> object.
|
|
<div><em>No exceptions.</em></div></dd></dl></div>
|
|
</div>
|
|
|
|
<div class="section" id="networking-model-changes">
|
|
<h4><span class="secno">4.3.2 </span>Changes to the networking model</h4>
|
|
|
|
<p>
|
|
When a <a class="externalDFN">cache host</a> is associated with an
|
|
<a class="externalDFN">application cache</a> whose
|
|
<a href="#dfn-dynamic-completeness-flag" class="internalDFN">dynamic completeness flag</a> is <var>complete</var>, any and all
|
|
loads for resources related to that <a class="externalDFN">cache host</a>
|
|
other than those for <a class="externalDFN">child browsing contexts</a>
|
|
must go through the following steps prior to the
|
|
the networking model for application caches defined in [<cite><a class="bibref" rel="biblioentry" href="#bib-HTML5">HTML5</a></cite>].
|
|
</p>
|
|
|
|
<ol>
|
|
<li>
|
|
Let <var>request</var> be the resource request for
|
|
<a title="fetch">fetching</a> the resource.
|
|
</li>
|
|
<li>
|
|
If <var>request</var> includes the HTTP header <code>Cache-Control</code>
|
|
with the value <code>no-cache</code>, then <a>fetch</a> the resource
|
|
normally, and abort these steps.
|
|
</li>
|
|
<li>
|
|
Let <var>cache</var> be the <a class="externalDFN">application cache</a>
|
|
for the <a class="externalDFN">cache host</a>.
|
|
</li>
|
|
<li>
|
|
Let <var>resource</var> be the resource to be <a title="fetch">fetched</a>.
|
|
</li>
|
|
<li>
|
|
If <var>resource</var> is not <a href="#dfn-managed" class="internalDFN">managed</a> in <var>cache</var>, then
|
|
<a class="externalDFN">fetch</a> a representation of <var>resource</var>
|
|
normally and abort these steps.
|
|
</li>
|
|
<li>
|
|
If <var>request</var> is using the HTTP <code>GET</code> mechanism
|
|
and <var>resource</var> is not defined in <var>cache</var> with a
|
|
<a title="dynamic methods" href="#dfn-dynamic-methods" class="internalDFN">dynamic <code>GET</code> method</a>,
|
|
then get the entity for <var>resource</var> from <var>cache</var>
|
|
(instead of <a class="externalDFN">fetching</a> it), and abort these steps.
|
|
</li>
|
|
<li>
|
|
If <var>request</var> is using the HTTP <code>HEAD</code> mechanism
|
|
and <var>resource</var> is not defined in <var>cache</var> with a
|
|
<a title="dynamic methods" href="#dfn-dynamic-methods" class="internalDFN">dynamic <code>HEAD</code> method</a>,
|
|
then get the entity headers for <var>resource</var> from <var>cache</var>
|
|
(instead of <a class="externalDFN">fetching</a> it), and abort these steps.
|
|
</li>
|
|
<li>
|
|
If <var>resource</var> is not defined in <var>cache</var> with the
|
|
<a title="dynamic methods" href="#dfn-dynamic-methods" class="internalDFN">dynamic method</a> that
|
|
<var>request</var> is using, then <a class="externalDFN">fetch</a> a
|
|
representation of <var>resource</var> normally and abort these steps.
|
|
</li>
|
|
<li>
|
|
Perform the steps to <a href="#dfn-select-an-embedded-local-server" class="internalDFN">select an embedded local server</a>
|
|
<var>server</var>.
|
|
</li>
|
|
<li>
|
|
If <var>server</var> is not set, then <a class="externalDFN">fetch</a>
|
|
a representation of <var>resource</var> normally and abort these steps.
|
|
</li>
|
|
<li>
|
|
Pick the appropriate steps:
|
|
<dl class="switch">
|
|
<dt>If the user agent is off-line</dt>
|
|
<dd><ol>
|
|
<li>
|
|
Create a new response object to hold the <a href="#dfn-dynamic" class="internalDFN">dynamic</a>
|
|
response to <var>request</var>.
|
|
</li>
|
|
<li>
|
|
Call the <a href="#dfn-interceptor" class="internalDFN">interceptor</a> function of <var>server</var>
|
|
passing as arguments <var>request</var> and <var>response</var>.
|
|
</li>
|
|
<li>
|
|
Wait for the <a href="#dfn-interceptor" class="internalDFN">interceptor</a> function to dispatch the
|
|
<a href="#dfn-dynamic" class="internalDFN">dynamic</a> response until the typical network timeout.
|
|
</li>
|
|
<li>
|
|
If the <a href="#dfn-dynamic" class="internalDFN">dynamic</a> response times out, then raise a
|
|
time out error and abort these steps.
|
|
</li>
|
|
<li>
|
|
Handle <var>response</var> as the <a href="#dfn-dynamic" class="internalDFN">dynamic</a> response,
|
|
and abort these steps.
|
|
</li>
|
|
</ol></dd>
|
|
<dt>If the user agent is online</dt>
|
|
<dd><ol>
|
|
<li>
|
|
If the <a href="#dfn-reviewer" class="internalDFN">reviewer</a> function of <var>server</var>
|
|
is not set, then abort these steps and perform the steps
|
|
for the case when the user agent is off-line.
|
|
</li>
|
|
<li>
|
|
<a class="externalDFN">Fetch</a> a representation of
|
|
<var>resource</var> normally and call it <var>response</var>.
|
|
</li>
|
|
<li>
|
|
Call the <a href="#dfn-reviewer" class="internalDFN">reviewer</a> function of <var>server</var> passing as
|
|
arguments <var>request</var> and <var>response</var>.
|
|
</li>
|
|
<li>
|
|
Handle <var>response</var> as the <a href="#dfn-dynamic" class="internalDFN">dynamic</a> response, and abort
|
|
these steps.
|
|
</li>
|
|
</ol></dd>
|
|
</dl>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="security" class="section">
|
|
<!--OddPage--><h2><span class="secno">5. </span>Security Considerations</h2>
|
|
<div class="ednote">
|
|
This section is not complete.
|
|
</div>
|
|
<p>
|
|
Apart from requirements affecting security made throughout
|
|
this specification implementations may, at their discretion,
|
|
not expose certain headers, such as HttpOnly cookies.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="section appendix" id="acknowledgements">
|
|
<!--OddPage--><h2><span class="secno">A. </span>Acknowledgements</h2>
|
|
<div>
|
|
The editor of this specification was employed by Oracle Corp during its early
|
|
drafts.
|
|
</div>
|
|
<div>
|
|
Thanks to Garret Swart, Colm Divilly, Ashish Motivala, Joseph Pecoraro, and Mike Wilson
|
|
for their useful comments that have led to improvements to this specification over time.
|
|
</div>
|
|
</div>
|
|
|
|
<div id="references" class="appendix section"><!--OddPage--><h2><span class="secno">B. </span>References</h2><div id="normative-references" class="section"><h3><span class="secno">B.1 </span>Normative references</h3><dl class="bibliography"><dt id="bib-COOKIES">[COOKIES]</dt><dd>Adam Barth. <cite><a href="http://tools.ietf.org/html/draft-abarth-cookie">HTTP State Management Mechanism</a>.</cite> IETF, November 2009
|
|
</dd><dt id="bib-DOM-LEVEL-3-CORE">[DOM-LEVEL-3-CORE]</dt><dd>Gavin Nicol; et al. <a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407"><cite>Document Object Model (DOM) Level 3 Core Specification.</cite></a> 7 April 2004. W3C Recommendation. URL: <a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407">http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407</a>
|
|
</dd><dt id="bib-DOM-LEVEL-3-EVENTS">[DOM-LEVEL-3-EVENTS]</dt><dd>Björn Höhrmann; Tom Pixley; Philippe Le Hégaret. <a href="http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221"><cite>Document Object Model (DOM) Level 3 Events Specification.</cite></a> 21 December 2007. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221">http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221</a>
|
|
</dd><dt id="bib-FILE-API">[FILE-API]</dt><dd>Arun Ranganathan. <a href="http://www.w3.org/TR/2009/WD-FileAPI-20091117/"><cite>File API.</cite></a> 17 November 2009. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/2009/WD-FileAPI-20091117/">http://www.w3.org/TR/2009/WD-FileAPI-20091117/</a>
|
|
</dd><dt id="bib-HTML5">[HTML5]</dt><dd>Ian Hickson; David Hyatt. <a href="http://www.w3.org/TR/2010/WD-html5-20100304/"><cite>HTML 5.</cite></a> 4 March 2010. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/2010/WD-html5-20100304/">http://www.w3.org/TR/2010/WD-html5-20100304/</a>
|
|
</dd><dt id="bib-HTTP11">[HTTP11]</dt><dd>R. Fielding; et al. <a href="http://www.ietf.org/rfc/rfc2616.txt"><cite>Hypertext Transfer Protocol - HTTP/1.1.</cite></a> June 1999. Internet RFC 2616. URL: <a href="http://www.ietf.org/rfc/rfc2616.txt">http://www.ietf.org/rfc/rfc2616.txt</a>
|
|
</dd><dt id="bib-RFC2119">[RFC2119]</dt><dd>S. Bradner. <a href="http://www.ietf.org/rfc/rfc2119.txt"><cite>Key words for use in RFCs to Indicate Requirement Levels.</cite></a> March 1997. Internet RFC 2119. URL: <a href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a>
|
|
</dd><dt id="bib-RFC4627">[RFC4627]</dt><dd>D. Crockford <a href="http://www.ietf.org/rfc/rfc4627.txt">The application/json Media Type for JavaScript Object Notation (JSON)</a> July 2006. Internet RFC 4627. URL: <a href="http://www.ietf.org/rfc/rfc4627.txt">http://www.ietf.org/rfc/rfc4627.txt</a>
|
|
</dd><dt id="bib-WEBIDL">[WEBIDL]</dt><dd>Cameron McCormack. <a href="http://www.w3.org/TR/2008/WD-WebIDL-20081219"><cite>Web IDL.</cite></a> 19 December 2008. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/2008/WD-WebIDL-20081219">http://www.w3.org/TR/2008/WD-WebIDL-20081219</a>
|
|
</dd></dl></div><div id="informative-references" class="section"><h3><span class="secno">B.2 </span>Informative references</h3><dl class="bibliography"><dt id="bib-XMLHTTPREQUEST">[XMLHTTPREQUEST]</dt><dd>Anne van Kesteren. <a href="http://www.w3.org/TR/2008/WD-XMLHttpRequest-20080415"><cite>The XMLHttpRequest Object.</cite></a> 15 April 2008. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/2008/WD-XMLHttpRequest-20080415">http://www.w3.org/TR/2008/WD-XMLHttpRequest-20080415</a>
|
|
</dd></dl></div></div></body></html>
|