offline.html 141 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-US-x-Hixie" ><head><title>5.6 Offline Web applications &#8212; HTML5 </title><style type="text/css">
   pre { margin-left: 2em; white-space: pre-wrap; }
   h2 { margin: 3em 0 1em 0; }
   h3 { margin: 2.5em 0 1em 0; }
   h4 { margin: 2.5em 0 0.75em 0; }
   h5, h6 { margin: 2.5em 0 1em; }
   h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
   h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
   p { margin: 1em 0; }
   hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
   dl, dd { margin-top: 0; margin-bottom: 0; }
   dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
   dt + dt { margin-top: 0; }
   dd dt { margin-top: 0.25em; margin-bottom: 0; }
   dd p { margin-top: 0; }
   dd dl + p { margin-top: 1em; }
   dd table + p { margin-top: 1em; }
   p + * > li, dd li { margin: 1em 0; }
   dt, dfn { font-weight: bold; font-style: normal; }
   dt dfn { font-style: italic; }
   pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
   pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
   pre em { font-weight: bolder; font-style: normal; }
   @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
   var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
   table { border-collapse: collapse; border-style: hidden hidden none hidden; }
   table thead, table tbody { border-bottom: solid; }
   table tbody th:first-child { border-left: solid; }
   table tbody th { text-align: left; }
   table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
   blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }

   .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
   .matrix, .matrix td { border: none; text-align: right; }
   .matrix { margin-left: 2em; }
   .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
   .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
   .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }

   .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
   img.extra { float: right; }
   pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
   pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
   pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
   pre.css:first-line { color: #AAAA50; }
   dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
   hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
   dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
   dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
   dl.domintro dd p { margin: 0.5em 0; }
   dl.switch { padding-left: 2em; }
   dl.switch > dt { text-indent: -1.5em; }
   dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
   dl.triple { padding: 0 0 0 1em; }
   dl.triple dt, dl.triple dd { margin: 0; display: inline }
   dl.triple dt:after { content: ':'; }
   dl.triple dd:after { content: '\A'; white-space: pre; }
   .diff-old { text-decoration: line-through; color: silver; background: transparent; }
   .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
   a .diff-new { border-bottom: 1px blue solid; }

   h2 { page-break-before: always; }
   h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
   h1 + h2, hr + h2.no-toc { page-break-before: auto; }

   p  > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
   li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]), { border-bottom: solid #9999CC; }

   div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
   div.head p { margin: 0; }
   div.head h1 { margin: 0; }
   div.head .logo { float: right; margin: 0 1em; }
   div.head .logo img { border: none } /* remove border from top image */
   div.head dl { margin: 1em 0; }
   div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }

   body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
   body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
   body > .toc > li > * { margin-bottom: 0.5em; }
   body > .toc > li > * > li > * { margin-bottom: 0.25em; }
   .toc, .toc li { list-style: none; }

   .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
   .brief li { margin: 0; padding: 0; }
   .brief li p { margin: 0; padding: 0; }

   .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
   .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
   .category-list li { display: inline; }
   .category-list li:not(:last-child)::after { content: ', '; }
   .category-list li > span, .category-list li > a { text-transform: lowercase; }
   .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */

   .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
   .XXX > :first-child { margin-top: 0; }
   p .XXX { line-height: 3em; }
   .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
   .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
   .annotation :link, .annotation :visited { color: inherit; }
   .annotation :link:hover, .annotation :visited:hover { background: transparent; }
   .annotation span { border: none ! important; }
   .note { color: green; background: transparent; font-family: sans-serif; }
   .warning { color: red; background: transparent; }
   .note, .warning { font-weight: bolder; font-style: italic; }
   p.note, div.note { padding: 0.5em 2em; }
   span.note { padding: 0 2em; }
   .note p:first-child, .warning p:first-child { margin-top: 0; }
   .note p:last-child, .warning p:last-child { margin-bottom: 0; }
   .warning:before { font-style: normal; }
   p.note:before { content: 'Note: '; }
   p.warning:before { content: '\26A0 Warning! '; }

   .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
   .bookkeeping { font-size: 0.8em; margin: 2em 0; }
   .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
   .bookkeeping dt { margin: 0.5em 2em 0; }
   .bookkeeping dd { margin: 0 3em 0.5em; }

   h4 { position: relative; z-index: 3; }
   h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
   .element {
     background: #EEEEFF;
     color: black;
     margin: 0 0 1em 0.15em;
     padding: 0 1em 0.25em 0.75em;
     border-left: solid #9999FF 0.25em;
     position: relative;
     z-index: 1;
   }
   .element:before {
     position: absolute;
     z-index: 2;
     top: 0;
     left: -1.15em;
     height: 2em;
     width: 0.9em;
     background: #EEEEFF;
     content: ' ';
     border-style: none none solid solid;
     border-color: #9999FF;
     border-width: 0.25em;
   }

   .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
   td > .example:only-child { margin: 0 0 0 0.1em; }

   ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
   ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
   ul.domTree li li { list-style: none; }
   ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
   ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
   ul.domTree span { font-style: italic; font-family: serif; }
   ul.domTree .t1 code { color: purple; font-weight: bold; }
   ul.domTree .t2 { font-style: normal; font-family: monospace; }
   ul.domTree .t2 .name { color: black; font-weight: bold; }
   ul.domTree .t2 .value { color: blue; font-weight: normal; }
   ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
   ul.domTree .t7 code, .domTree .t8 code { color: green; }
   ul.domTree .t10 code { color: teal; }

   body.dfnEnabled dfn { cursor: pointer; }
   .dfnPanel {
     display: inline;
     position: absolute;
     z-index: 10;
     height: auto;
     width: auto;
     padding: 0.5em 0.75em;
     font: small sans-serif, Droid Sans Fallback;
     background: #DDDDDD;
     color: black;
     border: outset 0.2em;
   }
   .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
   .dfnPanel :link, .dfnPanel :visited { color: black; }
   .dfnPanel p { font-weight: bolder; }
   .dfnPanel * + p { margin-top: 0.25em; }
   .dfnPanel li { list-style-position: inside; }

   #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
   #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
   #configUI p label { display: block; }
   #configUI #updateUI, #configUI .loginUI { text-align: center; }
   #configUI input[type=button] { display: block; margin: auto; }

   fieldset { margin: 1em; padding: 0.5em 1em; }
   fieldset > legend + * { margin-top: 0; }
   fieldset > :last-child { margin-bottom: 0; }
   fieldset p { margin: 0.5em 0; }

   .stability {
     position: fixed;
     bottom: 0;
     left: 0; right: 0;
     margin: 0 auto 0 auto !important;
    z-index: 1000;
     width: 50%;
     background: maroon; color: yellow;
     -webkit-border-radius: 1em 1em 0 0;
     -moz-border-radius: 1em 1em 0 0;
     border-radius: 1em 1em 0 0;
     -moz-box-shadow: 0 0 1em #500;
     -webkit-box-shadow: 0 0 1em #500;
     box-shadow: 0 0 1em red;
     padding: 0.5em 1em;
     text-align: center;
   }
   .stability strong {
     display: block;
   }
   .stability input {
     appearance: none; margin: 0; border: 0; padding: 0.25em 0.5em; background: transparent; color: black;
     position: absolute; top: -0.5em; right: 0; font: 1.25em sans-serif; text-align: center;
   }
   .stability input:hover {
     color: white;
     text-shadow: 0 0 2px black;
   }
   .stability input:active {
     padding: 0.3em 0.45em 0.2em 0.55em;
   }
   .stability :link, .stability :visited,
   .stability :link:hover, .stability :visited:hover {
     background: transparent;
     color: white;
   }

  </style><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation
requirements"><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css"><style type="text/css">

   .applies thead th > * { display: block; }
   .applies thead code { display: block; }
   .applies tbody th { whitespace: nowrap; }
   .applies td { text-align: center; }
   .applies .yes { background: yellow; }

   .matrix, .matrix td { border: hidden; text-align: right; }
   .matrix { margin-left: 2em; }

   .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
   .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
   .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }

   td.eg { border-width: thin; text-align: center; }

   #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
   #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
   #table-example-1 caption { padding-bottom: 0.5em; }
   #table-example-1 thead, #table-example-1 tbody { border: none; }
   #table-example-1 th, #table-example-1 td { border: solid thin; }
   #table-example-1 th { font-weight: normal; }
   #table-example-1 td { border-style: none solid; vertical-align: top; }
   #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
   #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
   #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
   #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
   #table-example-1 tbody td:first-child::after { content: leader(". "); }
   #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
   #table-example-1 tbody td:first-child + td { width: 10em; }
   #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
   #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }

   .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
   .apple-table-examples * { font-family: "Times", serif; }
   .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
   .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
   .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
   .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
   .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
   .apple-table-examples td { text-align: right; vertical-align: top; }
   .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
   .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
   .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
   .apple-table-examples sup { line-height: 0; }

   .details-example img { vertical-align: top; }

   #base64-table {
     white-space: nowrap;
     font-size: 0.6em;
     column-width: 6em;
     column-count: 5;
     column-gap: 1em;
     -moz-column-width: 6em;
     -moz-column-count: 5;
     -moz-column-gap: 1em;
     -webkit-column-width: 6em;
     -webkit-column-count: 5;
     -webkit-column-gap: 1em;
   }
   #base64-table thead { display: none; }
   #base64-table * { border: none; }
   #base64-table tbody td:first-child:after { content: ':'; }
   #base64-table tbody td:last-child { text-align: right; }

   #named-character-references-table {
     white-space: nowrap;
     font-size: 0.6em;
     column-width: 30em;
     column-gap: 1em;
     -moz-column-width: 30em;
     -moz-column-gap: 1em;
     -webkit-column-width: 30em;
     -webkit-column-gap: 1em;
   }
   #named-character-references-table > table > tbody > tr > td:first-child + td,
   #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
   #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
   #named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }

   .glyph.control { color: red; }

   @font-face {
     font-family: 'Essays1743';
     src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
   }
   @font-face {
     font-family: 'Essays1743';
     font-weight: bold;
     src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
   }
   @font-face {
     font-family: 'Essays1743';
     font-style: italic;
     src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
   }
   @font-face {
     font-family: 'Essays1743';
     font-style: italic;
     font-weight: bold;
     src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
   }

  </style><style type="text/css">
   .domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
  </style><script type="text/javascript">
   function getCookie(name) {
     var params = location.search.substr(1).split("&");
     for (var index = 0; index < params.length; index++) {
       if (params[index] == name)
         return "1";
       var data = params[index].split("=");
       if (data[0] == name)
         return unescape(data[1]);
     }
     var cookies = document.cookie.split("; ");
     for (var index = 0; index < cookies.length; index++) {
       var data = cookies[index].split("=");
       if (data[0] == name)
         return unescape(data[1]);
     }
     return null;
   }
  </script>
  <script src="link-fixup.js" type="text/javascript"></script>
  <link href="style.css" rel="stylesheet"><link href="history.html" title="5.4 Session history and navigation" rel="prev">
  <link href="spec.html#contents" title="Table of contents" rel="index">
  <link href="webappapis.html" title="6 Web application APIs" rel="next">
  </head><body><div class="head" id="head">
<div id="multipage-common">
  <p class="stability" id="wip"><strong>This is a work in
  progress!</strong> For the latest updates from the HTML WG, possibly
  including important bug fixes, please look at the <a href="http://dev.w3.org/html5/spec/Overview.html">editor's draft</a> instead.
  There may also be a more
  <a href="http://www.w3.org/TR/html5">up-to-date Working Draft</a>
   with changes based on resolution of Last Call issues.
  <input onclick="closeWarning(this.parentNode)" type="button" value="&#9587;&#8413;"></p>
  <script type="text/javascript">
   function closeWarning(element) {
     element.parentNode.removeChild(element);
     var date = new Date();
     date.setDate(date.getDate()+4);
     document.cookie = 'hide-obsolescence-warning=1; expires=' + date.toGMTString();
   }
   if (getCookie('hide-obsolescence-warning') == '1')
     setTimeout(function () { document.getElementById('wip').parentNode.removeChild(document.getElementById('wip')); }, 2000);
  </script></div>

   <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>

   <h1>HTML5</h1>
   </div><div>
   <a href="history.html" class="prev">5.4 Session history and navigation</a> &#8211;
   <a href="spec.html#contents">Table of contents</a> &#8211;
   <a href="webappapis.html" class="next">6 Web application APIs</a>
  <ol class="toc"><li><ol><li><a href="offline.html#offline"><span class="secno">5.6 </span>Offline Web applications</a>
    <ol><li><a href="offline.html#introduction-4"><span class="secno">5.6.1 </span>Introduction</a>
      <ol><li><a href="offline.html#appcacheevents"><span class="secno">5.6.1.1 </span>Event summary</a></li></ol></li><li><a href="offline.html#appcache"><span class="secno">5.6.2 </span>Application caches</a></li><li><a href="offline.html#manifests"><span class="secno">5.6.3 </span>The cache manifest syntax</a>
      <ol><li><a href="offline.html#some-sample-manifests"><span class="secno">5.6.3.1 </span>Some sample manifests</a></li><li><a href="offline.html#writing-cache-manifests"><span class="secno">5.6.3.2 </span>Writing cache manifests</a></li><li><a href="offline.html#parsing-cache-manifests"><span class="secno">5.6.3.3 </span>Parsing cache manifests</a></li></ol></li><li><a href="offline.html#downloading-or-updating-an-application-cache"><span class="secno">5.6.4 </span>Downloading or updating an application cache</a></li><li><a href="offline.html#the-application-cache-selection-algorithm"><span class="secno">5.6.5 </span>The application cache selection algorithm</a></li><li><a href="offline.html#changesToNetworkingModel"><span class="secno">5.6.6 </span>Changes to the networking model</a></li><li><a href="offline.html#expiring-application-caches"><span class="secno">5.6.7 </span>Expiring application caches</a></li><li><a href="offline.html#disk-space"><span class="secno">5.6.8 </span>Disk space</a></li><li><a href="offline.html#application-cache-api"><span class="secno">5.6.9 </span>Application cache API</a></li><li><a href="offline.html#browser-state"><span class="secno">5.6.10 </span>Browser state</a></li></ol></li></ol></li></ol></div>

  <h3 id="offline"><span class="secno">5.6 </span>Offline Web applications</h3><h4 id="introduction-4"><span class="secno">5.6.1 </span>Introduction</h4><p><i>This section is non-normative.</i></p><p>In order to enable users to continue interacting with Web
  applications and documents even when their network connection is
  unavailable &#8212; for instance, because they are traveling outside
  of their ISP's coverage area &#8212; authors can provide a manifest
  which lists the files that are needed for the Web application to
  work offline and which causes the user's browser to keep a copy of
  the files for use offline.</p><p>To illustrate this, consider a simple clock applet consisting of
  an HTML page "<code title="">clock.html</code>", a CSS style sheet
  "<code title="">clock.css</code>", and a JavaScript script "<code title="">clock.js</code>".</p><p>Before adding the manifest, these three files might look like
  this:</p><pre>&lt;!-- clock.html --&gt;
&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;title&gt;Clock&lt;/title&gt;
  &lt;script src="clock.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" href="clock.css"&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;p&gt;The time is: &lt;output id="clock"&gt;&lt;/output&gt;&lt;/p&gt;
 &lt;/body&gt;
&lt;/html&gt;</pre><pre>/* clock.css */
output { font: 2em sans-serif; }</pre><pre>/* clock.js */
setTimeout(function () {
    document.getElementById('clock').value = new Date();
}, 1000);</pre><p>If the user tries to open the "<code title="">clock.html</code>"
  page while offline, though, the user agent (unless it happens to
  have it still in the local cache) will fail with an error.</p><p>The author can instead provide a manifest of the three files:</p><pre>CACHE MANIFEST
clock.html
clock.css
clock.js</pre><p>With a small change to the HTML file, the manifest (served as
  <code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code>) is linked to the application:</p><pre>&lt;!-- clock.html --&gt;
&lt;!DOCTYPE HTML&gt;
&lt;html manifest="clock.appcache"&gt;
 &lt;head&gt;
  &lt;title&gt;Clock&lt;/title&gt;
  &lt;script src="clock.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" href="clock.css"&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;p&gt;The time is: &lt;output id="clock"&gt;&lt;/output&gt;&lt;/p&gt;
 &lt;/body&gt;
&lt;/html&gt;</pre><p>Now, if the user goes to the page, the browser will cache the
  files and make them available even when the user is offline.</p><p class="note">Authors are encouraged to include the main page in
  the manifest also, but in practice the page that referenced the
  manifest is automatically cached even if it isn't explicitly
  mentioned.</p><p class="note">HTTP cache headers and restrictions on caching pages
  served over TLS (encrypted, using <code title="">https:</code>) are
  overridden by manifests. Thus, pages will not expire from an
  application cache before the user agent has updated it, and even
  applications served over TLS can be made to work offline.</p><h5 id="appcacheevents"><span class="secno">5.6.1.1 </span>Event summary</h5><p><i>This section is non-normative.</i></p><p>When the user visits a page that declares a manifest, the browser
  will try to update the cache. It does this by fetching a copy of the
  manifest and, if the manifest has changed since the user agent last
  saw it, redownloading all the resources it mentions and caching them
  anew.</p><p>As this is going on, a number of events get fired on the
  <code><a href="#applicationcache">ApplicationCache</a></code> object to keep the script updated as
  to the state of the cache update, so that the user can be notified
  appropriately. The events are as follows:</p><table><thead><tr><th> Event name
     </th><th> Interface
     </th><th> Dispatched when...
     </th><th> Next events
   </th></tr></thead><tbody><tr><td> <dfn id="event-appcache-checking" title="event-appcache-checking"><code>checking</code></dfn>
     </td><td> <code><a href="infrastructure.html#event">Event</a></code>
     </td><td> The user agent is checking for an update, or attempting to download the manifest for the first time. <strong>This is always the first event in the sequence.</strong>
     </td><td> <code title="event-appcache-noupdate"><a href="#event-appcache-noupdate">noupdate</a></code>, <code title="event-appcache-downloading"><a href="#event-appcache-downloading">downloading</a></code>, <code title="event-appcache-obsolete"><a href="#event-appcache-obsolete">obsolete</a></code>, <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code>
    </td></tr><tr><td> <dfn id="event-appcache-noupdate" title="event-appcache-noupdate"><code>noupdate</code></dfn>
     </td><td> <code><a href="infrastructure.html#event">Event</a></code>
     </td><td> The manifest hadn't changed.
     </td><td> Last event in sequence.
    </td></tr><tr><td> <dfn id="event-appcache-downloading" title="event-appcache-downloading"><code>downloading</code></dfn>
     </td><td> <code><a href="infrastructure.html#event">Event</a></code>
     </td><td> The user agent has found an update and is fetching it, or is downloading the resources listed by the manifest for the first time.
     </td><td> <code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>, <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code>, <code title="event-appcache-cached"><a href="#event-appcache-cached">cached</a></code>, <code title="event-appcache-updateready"><a href="#event-appcache-updateready">updateready</a></code>
    </td></tr><tr><td> <dfn id="event-appcache-progress" title="event-appcache-progress"><code>progress</code></dfn>
     </td><td> <code>ProgressEvent</code>
     </td><td> The user agent is downloading resources listed by the manifest.
     </td><td> <code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>, <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code>, <code title="event-appcache-cached"><a href="#event-appcache-cached">cached</a></code>, <code title="event-appcache-updateready"><a href="#event-appcache-updateready">updateready</a></code>
    </td></tr><tr><td> <dfn id="event-appcache-cached" title="event-appcache-cached"><code>cached</code></dfn>
     </td><td> <code><a href="infrastructure.html#event">Event</a></code>
     </td><td> The resources listed in the manifest have been downloaded, and the application is now cached.
     </td><td> Last event in sequence.
    </td></tr><tr><td> <dfn id="event-appcache-updateready" title="event-appcache-updateready"><code>updateready</code></dfn>
     </td><td> <code><a href="infrastructure.html#event">Event</a></code>
     </td><td> The resources listed in the manifest have been newly redownloaded, and the script can use <code title="dom-appcache-swapCache"><a href="#dom-appcache-swapcache">swapCache()</a></code> to switch to the new cache.
     </td><td> Last event in sequence.
    </td></tr><tr><td> <dfn id="event-appcache-obsolete" title="event-appcache-obsolete"><code>obsolete</code></dfn>
     </td><td> <code><a href="infrastructure.html#event">Event</a></code>
     </td><td> The manifest was found to have become a 404 or 410 page, so the application cache is being deleted.
     </td><td> Last event in sequence.
    </td></tr><tr><td rowspan="4"> <dfn id="event-appcache-error" title="event-appcache-error"><code>error</code></dfn>
     </td><td rowspan="4"> <code><a href="infrastructure.html#event">Event</a></code>
     </td><td> The manifest was a 404 or 410 page, so the attempt to cache the application has been aborted.
     </td><td rowspan="3"> Last event in sequence.
    </td></tr><tr><td> The manifest hadn't changed, but the page referencing the manifest failed to download properly.
    </td></tr><tr><td> A fatal error occurred while fetching the resources listed in the manifest.
    </td></tr><tr><td> The manifest changed while the update was being run.
     </td><td> The user agent will try fetching the files again momentarily.
  </td></tr></tbody></table><div class="impl">

  <h4 id="appcache"><span class="secno">5.6.2 </span>Application caches</h4>

  <p>An <dfn id="application-cache">application cache</dfn> is a set of cached resources
  consisting of:</p>

  <ul><li>

    <p>One or more resources (including their out-of-band metadata,
    such as HTTP headers, if any), identified by URLs, each falling
    into one (or more) of the following categories:</p>

    <dl><dt><dfn id="concept-appcache-master" title="concept-appcache-master">Master entries</dfn>

     </dt><dd><p class="note">These are documents that were added to the
     cache because a <a href="browsers.html#browsing-context">browsing context</a> was <a href="history.html#navigate" title="navigate">navigated</a> to that document and the
     document indicated that this was its cache, using the <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute.</p>


     </dd><dt><dfn id="concept-appcache-manifest" title="concept-appcache-manifest">The manifest</dfn>

     </dt><dd><p class="note">This is the resource corresponding to the URL
     that was given in a master entry's <code><a href="semantics.html#the-html-element">html</a></code> element's
     <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute. The
     manifest is fetched and processed during the <a href="#application-cache-download-process">application
     cache download process</a>. All the <a href="#concept-appcache-master" title="concept-appcache-master">master entries</a> have the
     <a href="origin-0.html#same-origin" title="same origin">same origin</a> as the manifest.</p>


     </dd><dt><dfn id="concept-appcache-explicit" title="concept-appcache-explicit">Explicit entries</dfn>

     </dt><dd><p class="note">These are the resources that were listed in
     the cache's <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> in an <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit
     section</a>.</p>


     </dd><dt><dfn id="concept-appcache-fallback" title="concept-appcache-fallback">Fallback entries</dfn>

     </dt><dd><p class="note">These are the resources that were listed in
     the cache's <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> in a <a href="#concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback
     section</a>.</p>


    </dd></dl><p><a href="#concept-appcache-explicit" title="concept-appcache-explicit">Explicit entries</a>
    and <a href="#concept-appcache-fallback" title="concept-appcache-fallback">Fallback
    entries</a> can be marked as <dfn id="concept-appcache-foreign" title="concept-appcache-foreign">foreign</dfn>, which means that
    they have a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code>
    attribute but that it doesn't point at this cache's <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a>.</p>

    <p class="note">A URL in the list can be flagged with multiple
    different types, and thus an entry can end up being categorized as
    multiple entries. For example, an entry can be a manifest entry
    and an explicit entry at the same time, if the manifest is listed
    within the manifest.</p>

   </li>

   <li>

    <p>Zero or more <dfn id="concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
    namespaces</dfn>, each of which is mapped to a <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entry</a>.</p>

    <p class="note">These are URLs used as <a href="#concept-appcache-matches-fallback" title="concept-appcache-matches-fallback">prefix match
    patterns</a> for resources that are to be fetched from the
    network if possible, or to be replaced by the corresponding <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entry</a> if not.
    Each namespace URL has the <a href="origin-0.html#same-origin">same origin</a> as <a href="#concept-appcache-manifest" title="concept-appcache-manifest">the manifest</a>.</p>

   </li>

   <li>

    <p>Zero or more URLs that form the <dfn id="concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
    namespaces</dfn>.</p>

    <p class="note">These are used as prefix match patterns, and
    declare URLs that the user agent will never load from the cache
    but will instead always attempt to obtain from the network.</p>

   </li>

   <li>

    <p>An <dfn id="concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
    wildcard flag</dfn>, which is either <i title="">open</i> or <i title="">blocking</i>.</p>

    <p class="note">The <i title="">open</i> state indicates that any
    URL not listed as cached is to be implicitly treated as being in
    the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online
    whitelist namespaces</a>; the <i title="">blocking</i> state
    indicates that URLs not listed explicitly in the manifest are to
    be treated as unavailable.</p>

   </li>

  </ul><p>Each <a href="#application-cache">application cache</a> has a <dfn id="concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</dfn>, which is
  either <i>complete</i> or <i>incomplete</i>.</p>

  <hr><p>An <dfn id="application-cache-group">application cache group</dfn> is a group of <a href="#application-cache" title="application cache">application caches</a>, identified by
  the <a href="urls.html#absolute-url">absolute URL</a> of a resource <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> which is used to
  populate the caches in the group.</p>

  <p>An <a href="#application-cache">application cache</a> is <dfn id="concept-appcache-newer" title="concept-appcache-newer">newer</dfn> than another if it was
  created after the other (in other words, <a href="#application-cache" title="application
  cache">application caches</a> in an <a href="#application-cache-group">application cache
  group</a> have a chronological order).</p>

  <p>Only the newest <a href="#application-cache">application cache</a> in an
  <a href="#application-cache-group">application cache group</a> can have its <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> set to
  <i>incomplete</i>; the others are always all <i>complete</i>.</p>

  <p>Each <a href="#application-cache-group">application cache group</a> has an <dfn id="concept-appcache-status" title="concept-appcache-status">update status</dfn>, which is one of
  the following: <i>idle</i>, <i>checking</i>, <i>downloading</i>.</p>

  <p>A <dfn id="relevant-application-cache">relevant application cache</dfn> is an <a href="#application-cache">application
  cache</a> that is the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> in its <a href="#application-cache-group" title="application cache group">group</a> to be
  <i>complete</i>.</p>

  <p>Each <a href="#application-cache-group">application cache group</a> has a <dfn id="concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
  entries</dfn>. Each entry in this list consists of a resource and a
  corresponding <code><a href="infrastructure.html#document">Document</a></code> object. It is used during the
  <a href="#application-cache-download-process">application cache download process</a> to ensure that new
  master entries are cached even if the <a href="#application-cache-download-process">application cache
  download process</a> was already running for their
  <a href="#application-cache-group">application cache group</a> when they were loaded.</p>

  <p>An <a href="#application-cache-group">application cache group</a> can be marked as <dfn id="concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</dfn>, meaning that it
  must be ignored when looking at what <a href="#application-cache-group" title="application cache
  group">application cache groups</a> exist.</p>

  <hr><p>A <dfn id="cache-host">cache host</dfn> is a <code><a href="infrastructure.html#document">Document</a></code> or a
  <code>SharedWorkerGlobalScope</code> object. A <a href="#cache-host">cache
  host</a> can be associated with an <a href="#application-cache">application
  cache</a>.
  
  <a href="references.html#refsWEBWORKERS">[WEBWORKERS]</a>
  
  </p>

  <p>A <code><a href="infrastructure.html#document">Document</a></code> initially is not associated with an
  <a href="#application-cache">application cache</a>, but can become associated with one
  early during the page load process, when steps <a href="tree-construction.html#parser-appcache">in the parser</a> and in the <a href="history.html#navigate" title="navigate">navigation</a> sections cause <a href="#concept-appcache-init" title="concept-appcache-init">cache selection</a> to occur.</p>

  <p>A <code>SharedWorkerGlobalScope</code> can be associated with an
  <a href="#application-cache">application cache</a> when it is created.
  
  <a href="references.html#refsWEBWORKERS">[WEBWORKERS]</a>
  
  </p>

  <p>Each <a href="#cache-host">cache host</a> has an associated
  <code><a href="#applicationcache">ApplicationCache</a></code> object.</p>

  <hr><p>Multiple <a href="#application-cache" title="application cache">application
  caches</a> in different <a href="#application-cache-group" title="application cache
  group">application cache groups</a> can contain the same
  resource, e.g. if the manifests all reference that resource. If the
  user agent is to <dfn id="concept-appcache-selection" title="concept-appcache-selection">select an
  application cache</dfn> from a list of <a href="#relevant-application-cache" title="relevant
  application cache">relevant application caches</a> that contain a
  resource, the user agent must use the application cache that the
  user most likely wants to see the resource from, taking into account
  the following:</p>

  <ul><li>which application cache was most recently updated,

   </li><li>which application cache was being used to display the
   resource from which the user decided to look at the new resource,
   and

   </li><li>which application cache the user prefers.

  </li></ul><hr><p>A URL <dfn id="concept-appcache-matches-fallback" title="concept-appcache-matches-fallback">matches a
  fallback namespace</dfn> if there exists a <a href="#relevant-application-cache">relevant
  application cache</a> whose <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a>'s URL has the
  <a href="origin-0.html#same-origin">same origin</a> as the URL in question, and that has a
  <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>
  that is a <a href="infrastructure.html#prefix-match">prefix match</a> for the URL being examined. If
  multiple fallback namespaces match the same URL, the longest one is
  the one that matches. A URL looking for a fallback namespace can
  match more than one application cache at a time, but only matches
  one namespace in each cache.</p>

  <div class="example">

   <p>If a manifest <code title="">http://example.com/app1/manifest</code> declares that
   <code title="">http://example.com/resources/images</code> is a
   fallback namespace, and the user navigates to <code title="">HTTP://EXAMPLE.COM:80/resources/images/cat.png</code>,
   then the user agent will decide that the application cache
   identified by <code title="">http://example.com/app1/manifest</code> contains a
   namespace with a match for that URL.</p>

   
  </div>

  </div><h4 id="manifests"><span class="secno">5.6.3 </span>The cache manifest syntax</h4><h5 id="some-sample-manifests"><span class="secno">5.6.3.1 </span>Some sample manifests</h5><p><i>This section is non-normative.</i></p><div class="example">

   <p>This example manifest requires two images and a style sheet to be
   cached and whitelists a CGI script.</p>

   <pre>CACHE MANIFEST
# the above line is required

# this is a comment
# there can be as many of these anywhere in the file
# they are all ignored
  # comments can have spaces before them
  # but must be alone on the line

# blank lines are ignored too

# these are files that need to be cached they can either be listed
# first, or a "CACHE:" header could be put before them, as is done
# lower down.
images/sound-icon.png
images/background.png
# note that each file has to be put on its own line

# here is a file for the online whitelist -- it isn't cached, and
# references to this file will bypass the cache, always hitting the
# network (or trying to, if the user is offline).
NETWORK:
comm.cgi

# here is another set of files to cache, this time just the CSS file.
CACHE:
style/default.css</pre>

   <p>It could equally well be written as follows:</p>

   <pre>CACHE MANIFEST
NETWORK:
comm.cgi
CACHE:
style/default.css
images/sound-icon.png
images/background.png</pre>

  </div><div class="example">

   <p>Offline application cache manifests can use absolute paths or
   even absolute URLs:</p>

   <pre>CACHE MANIFEST

/main/home
/main/app.js
/settings/home
/settings/app.js
http://img.example.com/logo.png
http://img.example.com/check.png
http://img.example.com/cross.png</pre>

  </div><div class="example">

   <p>The following manifest defines a catch-all error page that is
   displayed for any page on the site while the user is offline. It
   also specifies that the <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
   wildcard flag</a> is <i title="">open</i>, meaning that accesses
   to resources on other sites will not be blocked. (Resources on the
   same site are already not blocked because of the catch-all fallback
   namespace.)</p>

   <p>So long as all pages on the site reference this manifest, they
   will get cached locally as they are fetched, so that subsequent hits
   to the same page will load the page immediately from the
   cache. Until the manifest is changed, those pages will not be
   fetched from the server again. When the manifest changes, then all
   the files will be redownloaded.</p>

   <p>Subresources, such as style sheets, images, etc, would only be
   cached using the regular HTTP caching semantics, however.</p>

   <pre>CACHE MANIFEST
FALLBACK:
/ /offline.html
NETWORK:
*</pre>

  </div><h5 id="writing-cache-manifests"><span class="secno">5.6.3.2 </span>Writing cache manifests</h5><p>Manifests must be served using the
  <code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code> <a href="infrastructure.html#mime-type">MIME type</a>. All
  resources served using the <code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code>
  <a href="infrastructure.html#mime-type">MIME type</a> must follow the syntax of application cache
  manifests, as described in this section.</p><p>An application cache manifest is a text file, whose text is
  encoded using UTF-8. Data in application cache manifests is
  line-based. Newlines must be represented by U+000A LINE FEED (LF)
  characters, U+000D CARRIAGE RETURN (CR) characters, or U+000D
  CARRIAGE RETURN (CR) U+000A LINE FEED (LF) pairs. <a href="references.html#refsRFC3629">[RFC3629]</a></p><p class="note">This is a <a href="introduction.html#willful-violation">willful violation</a> of RFC
  2046, which requires all <code title="">text/*</code> types to only
  allow CRLF line breaks. This requirement, however, is outdated; the
  use of CR, LF, and CRLF line breaks is commonly supported and indeed
  sometimes CRLF is <em>not</em> supported by text editors. <a href="references.html#refsRFC2046">[RFC2046]</a></p><p>The first line of an application cache manifest must consist of
  the string "CACHE", a single U+0020 SPACE character, the string
  "MANIFEST", and either a U+0020 SPACE character, a U+0009 CHARACTER
  TABULATION (tab) character, a U+000A LINE FEED (LF) character, or a
  U+000D CARRIAGE RETURN (CR) character. The first line may optionally
  be preceded by a U+FEFF BYTE ORDER MARK (BOM) character. If any
  other text is found on the first line, it is ignored.</p><p>Subsequent lines, if any, must all be one of the following:</p><dl><dt>A blank line
   </dt><dd>
    <p>Blank lines must consist of zero or more U+0020 SPACE and
    U+0009 CHARACTER TABULATION (tab) characters only.</p>

   </dd><dt>A comment
   </dt><dd>
    <p>Comment lines must consist of zero or more U+0020 SPACE and
    U+0009 CHARACTER TABULATION (tab) characters, followed by a single
    U+0023 NUMBER SIGN character (#), followed by zero or more
    characters other than U+000A LINE FEED (LF) and U+000D CARRIAGE
    RETURN (CR) characters.</p>

    <p class="note">Comments must be on a line on their own. If they
    were to be included on a line with a URL, the "#" would be
    mistaken for part of a fragment identifier.</p>

   </dd><dt>A section header
   </dt><dd>
    <p>Section headers change the current section. There are three
    possible section headers:

    </p><dl><dt><code>CACHE:</code>
     </dt><dd>Switches to the <dfn id="concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit section</dfn>.

     </dd><dt><code>FALLBACK:</code>
     </dt><dd>Switches to the <dfn id="concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback section</dfn>.

     </dd><dt><code>NETWORK:</code>
     </dt><dd>Switches to the <dfn id="concept-appcache-manifest-network" title="concept-appcache-manifest-network">online whitelist section</dfn>.

    </dd></dl><p>Section header lines must consist of zero or more U+0020 SPACE
    and U+0009 CHARACTER TABULATION (tab) characters, followed by one
    of the names above (including the U+003A COLON character (:))
    followed by zero or more U+0020 SPACE and U+0009 CHARACTER
    TABULATION (tab) characters.</p>

    <p>Ironically, by default, the current section is the
    <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit section</a>.</p>

   </dd><dt>Data for the current section
   </dt><dd>
    <p>The format that data lines must take depends on the current
    section.</p>

    <p>When the current section is the <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit
    section</a>, data lines must consist of zero or more U+0020
    SPACE and U+0009 CHARACTER TABULATION (tab) characters, a
    <a href="urls.html#valid-url">valid URL</a> identifying a resource other than the
    manifest itself, and then zero or more U+0020 SPACE and U+0009
    CHARACTER TABULATION (tab) characters.</p>

    <p>When the current section is the <a href="#concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback
    section</a>, data lines must consist of zero or more U+0020
    SPACE and U+0009 CHARACTER TABULATION (tab) characters, a
    <a href="urls.html#valid-url">valid URL</a> identifying a resource other than the
    manifest itself, one or more U+0020 SPACE and U+0009 CHARACTER
    TABULATION (tab) characters, another <a href="urls.html#valid-url">valid URL</a>
    identifying a resource other than the manifest itself, and then
    zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab)
    characters.</p>

    <p>When the current section is the <a href="#concept-appcache-manifest-network" title="concept-appcache-manifest-network">online whitelist
    section</a>, data lines must consist of zero or more U+0020
    SPACE and U+0009 CHARACTER TABULATION (tab) characters, either a
    single U+002A ASTERISK character (*)  or a <a href="urls.html#valid-url">valid
    URL</a> identifying a resource other than the manifest itself,
    and then zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION
    (tab) characters.</p>


  </dd></dl><p>Manifests may contain sections more than once. Sections may be
  empty.</p><p>If the manifest's <a href="urls.html#url-scheme" title="url-scheme">&lt;scheme&gt;</a>
  is <code title="">https:</code> or another scheme intended for
  encrypted data transfer, then all URLs in <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit sections</a>
  must have the <a href="origin-0.html#same-origin">same origin</a> as the manifest itself.</p><p>URLs that are to be fallback pages associated with <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespaces</a>, and
  those namespaces themselves, must be given in <a href="#concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback sections</a>,
  with the namespace being the first URL of the data line, and the
  corresponding fallback page being the second URL. All the other
  pages to be cached must be listed in <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit
  sections</a>.</p><p><a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">Fallback
  namespaces</a> and <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entries</a> must have
  the <a href="origin-0.html#same-origin">same origin</a> as the manifest itself.</p><p>A <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
  namespace</a> must not be listed more than once.</p><p>Namespaces that the user agent is to put into the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a>
  must all be specified in <a href="#concept-appcache-manifest-network" title="concept-appcache-manifest-network">online whitelist
  sections</a>. (This is needed for any URL that the page is
  intending to use to communicate back to the server.) To specify that
  all URLs are automatically whitelisted in this way, a U+002A
  ASTERISK character (*) may be specified as one of the URLs. </p><p>Authors should not include namespaces in the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a> for
  which another namespace in the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a> is
  a <a href="infrastructure.html#prefix-match">prefix match</a>.</p><p>Relative URLs must be given relative to the manifest's own
  URL. All URLs in the manifest must have the same <a href="urls.html#url-scheme" title="url-scheme">&lt;scheme&gt;</a> as the manifest itself
  (either explicitly or implicitly, through the use of relative
  URLs).</p><p>URLs in manifests must not have fragment identifiers (i.e. the
  U+0023 NUMBER SIGN character isn't allowed in URLs in
  manifests).</p><p><a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">Fallback
  namespaces</a> and namespaces in the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a> are
  matched by <a href="infrastructure.html#prefix-match">prefix match</a>.</p><div class="impl">

  <h5 id="parsing-cache-manifests"><span class="secno">5.6.3.3 </span>Parsing cache manifests</h5>

  <p>When a user agent is to <dfn id="parse-a-manifest">parse a manifest</dfn>, it means
  that the user agent must run the following steps:</p>

  <ol><li><p>The user agent must decode the byte stream corresponding
   with the manifest to be parsed <a href="infrastructure.html#decoded-as-utf-8-with-error-handling" title="decoded as UTF-8, with
   error handling">as UTF-8, with error handling</a>. </p></li>

   <li><p>Let <var title="">base URL</var> be the <a href="urls.html#absolute-url">absolute
   URL</a> representing the manifest.</p></li>

   <li><p>Let <var title="">explicit URLs</var> be an initially empty
   list of <a href="urls.html#absolute-url" title="absolute URL">absolute URLs</a> for <a href="#concept-appcache-explicit" title="concept-appcache-explicit">explicit entries</a>.</p></li>

   <li><p>Let <var title="">fallback URLs</var> be an initially empty
   mapping of <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
   namespaces</a> to <a href="urls.html#absolute-url" title="absolute URL">absolute
   URLs</a> for <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback
   entries</a>.</p></li>

   <li><p>Let <var title="">online whitelist namespaces</var> be an
   initially empty list of <a href="urls.html#absolute-url" title="absolute URL">absolute
   URLs</a> for an <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online
   whitelist</a>.</p></li>

   <li><p>Let <var title="">online whitelist wildcard flag</var> be <i title="">blocking</i>. </p></li>

   <li><p>Let <var title="">input</var> be the decoded text of the
   manifest's byte stream.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the first
   character.</p></li>

   <li><p>If <var title="">position</var> is pointing at a U+FEFF BYTE
   ORDER MARK (BOM) character, then advance <var title="">position</var> to the next character.</p></li>

   <li><p>If the characters starting from <var title="">position</var>
   are "CACHE", followed by a U+0020 SPACE character, followed by
   "MANIFEST", then advance <var title="">position</var> to the next
   character after those. Otherwise, this isn't a cache manifest;
   abort this algorithm with a failure while checking for the magic
   signature.</p></li>

   <li><p>If the character at <var title="">position</var> is neither
   a U+0020 SPACE character, a U+0009 CHARACTER TABULATION (tab)
   character, U+000A LINE FEED (LF) character, nor a U+000D CARRIAGE
   RETURN (CR) character, then this isn't a cache manifest; abort this
   algorithm with a failure while checking for the magic
   signature.</p></li>

   <li><p>This is a cache manifest. The algorithm cannot fail beyond
   this point (though bogus lines can get ignored).</p></li>

   <li><p><a href="common-microsyntaxes.html#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are
   <em>not</em> U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)
   characters, and ignore those characters. (Extra text on the first
   line, after the signature, is ignored.)</p></li>

   <li><p>Let <var title="">mode</var> be "explicit".</p></li>

   <li><p><i>Start of line</i>: If <var title="">position</var> is
   past the end of <var title="">input</var>, then jump to the last
   step. Otherwise, <a href="common-microsyntaxes.html#collect-a-sequence-of-characters">collect a sequence of characters</a> that
   are U+000A LINE FEED (LF), U+000D CARRIAGE RETURN (CR), U+0020
   SPACE, or U+0009 CHARACTER TABULATION (tab) characters.</p></li>
   

   <li><p>Now, <a href="common-microsyntaxes.html#collect-a-sequence-of-characters">collect a sequence of characters</a> that are
   <em>not</em> U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)
   characters, and let the result be <var title="">line</var>.</p></li>

   <li><p>Drop any trailing U+0020 SPACE and U+0009 CHARACTER
   TABULATION (tab) characters at the end of <var title="">line</var>.</p></li>

   <li><p>If <var title="">line</var> is the empty string, then jump
   back to the step labeled "start of line".</p></li>

   <li><p>If the first character in <var title="">line</var> is a
   U+0023 NUMBER SIGN character (#), then jump back to the step
   labeled "start of line".</p></li>

   <li><p>If <var title="">line</var> equals "CACHE:" (the word
   "CACHE" followed by a U+003A COLON character (:)), then set <var title="">mode</var> to "explicit" and jump back to the step
   labeled "start of line".</p></li>

   <li><p>If <var title="">line</var> equals "FALLBACK:" (the word
   "FALLBACK" followed by a U+003A COLON character (:)), then set <var title="">mode</var> to "fallback" and jump back to the step
   labeled "start of line".</p></li>

   <li><p>If <var title="">line</var> equals "NETWORK:" (the word
   "NETWORK" followed by a U+003A COLON character (:)), then set <var title="">mode</var> to "online whitelist" and jump back to the step
   labeled "start of line".</p></li>

   <li><p>If <var title="">line</var> ends with a U+003A COLON
   character (:), then set <var title="">mode</var> to "unknown" and
   jump back to the step labeled "start of line".</p></li>

   <li><p>This is either a data line or it is syntactically
   incorrect.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var title="">line</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>Let <var title="">tokens</var> be a list of strings,
   initially empty.</p></li>

   <li>

    <p>While <var title="">position</var> doesn't point past the end
    of <var title="">line</var>:</p>

    <ol><li><p>Let <var title="">current token</var> be an empty
     string.</p></li>

     <li><p>While <var title="">position</var> doesn't point past the
     end of <var title="">line</var> and the character at <var title="">position</var> is neither a U+0020 SPACE nor a U+0009
     CHARACTER TABULATION (tab) character, add the character at <var title="">position</var> to <var title="">current token</var> and
     advance <var title="">position</var> to the next character in
     <var title="">input</var>.</p></li>

     <li><p>Add <var title="">current token</var> to the <var title="">tokens</var> list.</p></li>

     <li><p>While <var title="">position</var> doesn't point past the
     end of <var title="">line</var> and the character at <var title="">position</var> is either a U+0020 SPACE or a U+0009
     CHARACTER TABULATION (tab) character, advance <var title="">position</var> to the next character in <var title="">input</var>.</p></li>

    </ol></li>

   <li>

    <p>Process <var title="">tokens</var> as follows:</p>

    <dl class="switch"><dt>If <var title="">mode</var> is "explicit"</dt>

     <dd>

      <p><a href="urls.html#resolve-a-url" title="resolve a url">Resolve</a> the first item in
      <var title="">tokens</var>, relative to <var title="">base
      URL</var>; ignore the rest.</p>

      <p>If this fails, then jump back to the step labeled "start of
      line".</p>

      <p>If the resulting <a href="urls.html#absolute-url">absolute URL</a> has a different
      <a href="urls.html#url-scheme" title="url-scheme">&lt;scheme&gt;</a> component than
      the manifest's URL (compared in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
      case-insensitive</a> manner), then jump back to the step
      labeled "start of line". If the manifest's <a href="urls.html#url-scheme" title="url-scheme">&lt;scheme&gt;</a> is <code title="">https:</code> or another scheme intended for encrypted
      data transfer, and the resulting <a href="urls.html#absolute-url">absolute URL</a> does
      not have the <a href="origin-0.html#same-origin">same origin</a> as the manifest's URL,
      then jump back to the step labeled "start of line".</p>

      <p>Drop the <a href="urls.html#url-fragment" title="url-fragment">&lt;fragment&gt;</a>
      component of the resulting <a href="urls.html#absolute-url">absolute URL</a>, if it has
      one.</p>

      <p>Add the resulting <a href="urls.html#absolute-url">absolute URL</a> to the <var title="">explicit URLs</var>.</p>

     </dd>

     <dt>If <var title="">mode</var> is "fallback"</dt>

     <dd>

      <p>Let <var title="">part one</var> be the first token in <var title="">tokens</var>, and let <var title="">part two</var> be
      the second token in <var title="">tokens</var>.</p>

      <p><a href="urls.html#resolve-a-url" title="resolve a url">Resolve</a> <var title="">part
      one</var> and <var title="">part two</var>, relative to <var title="">base URL</var>.</p>

      <p>If either fails, then jump back to the step labeled "start of
      line".</p>

      <p>If the <a href="urls.html#absolute-url">absolute URL</a> corresponding to either <var title="">part one</var> or <var title="">part two</var> does not
      have the <a href="origin-0.html#same-origin">same origin</a> as the manifest's URL, then
      jump back to the step labeled "start of line".</p> 
      <p>Drop any <a href="urls.html#url-fragment" title="url-fragment">&lt;fragment&gt;</a>
      components of the resulting <a href="urls.html#absolute-url" title="absolute URL">absolute
      URLs</a>.</p>

      <p>If the <a href="urls.html#absolute-url">absolute URL</a> corresponding to <var title="">part one</var> is already in the <var title="">fallback
      URLs</var> mapping as a <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>,
      then jump back to the step labeled "start of line".</p>

      <p>Otherwise, add the <a href="urls.html#absolute-url">absolute URL</a> corresponding to
      <var title="">part one</var> to the <var title="">fallback
      URLs</var> mapping as a <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>,
      mapped to the <a href="urls.html#absolute-url">absolute URL</a> corresponding to <var title="">part two</var> as the <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entry</a>.</p>

     </dd>

     <dt>If <var title="">mode</var> is "online whitelist"</dt>

     <dd>

      <p>If the first item in <var title="">tokens</var> is a U+002A
      ASTERISK character (*), then set <var title="">online whitelist
      wildcard flag</var> to <i title="">open</i> and jump back to the
      step labeled "start of line".</p>

      <p>Otherwise, <a href="urls.html#resolve-a-url" title="resolve a url">resolve</a> the
      first item in <var title="">tokens</var>, relative to <var title="">base URL</var>; ignore the rest.</p>

      <p>If this fails, then jump back to the step labeled "start of
      line".</p>

      <p>If the resulting <a href="urls.html#absolute-url">absolute URL</a> has a different
      <a href="urls.html#url-scheme" title="url-scheme">&lt;scheme&gt;</a> component than
      the manifest's URL (compared in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
      case-insensitive</a> manner), then jump back to the step
      labeled "start of line".</p>

      <p>Drop the <a href="urls.html#url-fragment" title="url-fragment">&lt;fragment&gt;</a>
      component of the resulting <a href="urls.html#absolute-url">absolute URL</a>, if it has
      one.</p>

      <p>Add the resulting <a href="urls.html#absolute-url">absolute URL</a> to the <var title="">online whitelist namespaces</var>.</p>

     </dd>

     <dt>If <var title="">mode</var> is "unknown"</dt>

     <dd>

      <p>Do nothing. The line is ignored.</p>

     </dd>

    </dl></li>

   <li><p>Jump back to the step labeled "start of line". (That step
   jumps to the next, and last, step when the end of the file is
   reached.)</p></li>

   <li><p>Return the <var title="">explicit URLs</var> list, the <var title="">fallback URLs</var> mapping, the <var title="">online
   whitelist namespaces</var>, and the <var title="">online whitelist
   wildcard flag</var>.</p></li>

  </ol><div class="note">

   <p>The resource that declares the manifest (with the <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute) will always
   get taken from the cache, whether it is listed in the cache or not,
   even if it is listed in an <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
   namespace</a>.</p>

   <p>If a resource is listed in the <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit section</a>
   or as a <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback
   entry</a> in the <a href="#concept-appcache-manifest-fallback" title="concept-appcache-manifest-fallback">fallback section</a>,
   the resource will always be taken from the cache, regardless of any
   other matching entries in the <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespaces</a> or
   <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
   namespaces</a>.</p>

   <p>When a <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
   namespace</a> and an <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
   namespace</a> overlap, the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist
   namespace</a> has priority.</p>

   <p>The <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
   wildcard flag</a> is applied last, only for URLs that match
   neither the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online
   whitelist namespace</a> nor the <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a> and
   that are not listed in the <a href="#concept-appcache-manifest-explicit" title="concept-appcache-manifest-explicit">explicit
   section</a>.</p>

  </div>


  <h4 id="downloading-or-updating-an-application-cache"><span class="secno">5.6.4 </span>Downloading or updating an application cache</h4>

  <p>When the user agent is required (by other parts of this
  specification) to start the <dfn id="application-cache-download-process">application cache download
  process</dfn> for an <a href="urls.html#absolute-url">absolute URL</a> purported to identify
  a <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a>, or for an
  <a href="#application-cache-group">application cache group</a>, potentially given a particular
  <a href="#cache-host">cache host</a>, and potentially given a <a href="#concept-appcache-master" title="concept-appcache-master">master</a> resource, the user
  agent must run the steps below. These steps are always run
  asynchronously, in parallel with the <a href="webappapis.html#event-loop">event loop</a> <a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>

  <p>Some of these steps have requirements that only apply if the user
  agent <dfn id="shows-caching-progress">shows caching progress</dfn>. Support for this is
  optional. Caching progress UI could consist of a progress bar or
  message panel in the user agent's interface, or an overlay, or
  something else. Certain events fired during the <a href="#application-cache-download-process">application
  cache download process</a> allow the script to override the display
  of such an interface. The goal of this is to allow Web applications
  to provide more seamless update mechanisms, hiding from the user the
  mechanics of the application cache mechanism. User agents may
  display user interfaces independent of this, but are encouraged to
  not show prominent update progress notifications for applications
  that cancel the relevant events.</p>

  <p class="note">These events are delayed until after the <code title="event-load">load</code> event has fired.</p>

  <p>The <a href="#application-cache-download-process">application cache download process</a> steps are as
  follows:

  </p><ol><li><p>Optionally, wait until the permission to start the
   <a href="#application-cache-download-process">application cache download process</a> has been obtained
   from the user and until the user agent is confident that the
   network is available. This could include doing nothing until the
   user explicitly opts-in to caching the site, or could involve
   prompting the user for permission. The algorithm might never get
   past this point. (This step is particularly intended to be used by
   user agents running on severely space-constrained devices or in
   highly privacy-sensitive environments).</p></li>

   <li>

    <p>Atomically, so as to avoid race conditions, perform the
    following substeps:</p>

    <ol><li>

      <p>Pick the appropriate substeps:</p>

      <dl class="switch"><dt>If these steps were invoked with an <a href="urls.html#absolute-url">absolute
       URL</a> purported to identify a <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a></dt>

       <dd>

        <p>Let <var title="">manifest URL</var> be that <a href="urls.html#absolute-url">absolute
        URL</a>.</p>

        <p>If there is no <a href="#application-cache-group">application cache group</a>
        identified by <var title="">manifest URL</var>, then create a
        new <a href="#application-cache-group">application cache group</a> identified by <var title="">manifest URL</var>. Initially, it has no <a href="#application-cache" title="application cache">application caches</a>. One will
        be created later in this algorithm.</p>

       </dd>


       <dt>If these steps were invoked with an <a href="#application-cache-group">application cache
       group</a></dt>

       <dd>

        <p>Let <var title="">manifest URL</var> be the <a href="urls.html#absolute-url">absolute
        URL</a> of the <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> used to
        identify the <a href="#application-cache-group">application cache group</a> to be
        updated.</p>

        <p>If that <a href="#application-cache-group">application cache group</a> is <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>, then abort
        this instance of the <a href="#application-cache-download-process">application cache download
        process</a>. This can happen if another instance of this
        algorithm found the manifest to be 404 or 410 while this
        algorithm was waiting in the first step above.</p>

       </dd>

      </dl></li>

     <li><p>Let <var title="">cache group</var> be the
     <a href="#application-cache-group">application cache group</a> identified by <var title="">manifest URL</var>.</p></li>

     <li><p>If these steps were invoked with a <a href="#concept-appcache-master" title="concept-appcache-master">master</a> resource, then add
     the resource, along with the resource's <code><a href="infrastructure.html#document">Document</a></code>, to
     <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
     entries</a>.</p></li>

     <li><p>If these steps were invoked with a <a href="#cache-host">cache
     host</a>, and the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> is <i>checking</i> or
     <i>downloading</i>, then <a href="#queue-a-post-load-task">queue a post-load task</a> to
     <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <code title="event-appcache-checking"><a href="#event-appcache-checking">checking</a></code> that is
     cancelable at the <code><a href="#applicationcache">ApplicationCache</a></code> singleton of that
     <a href="#cache-host">cache host</a>. The default action of this event must
     be, if the user agent <a href="#shows-caching-progress">shows caching progress</a>, the
     display of some sort of user interface indicating to the user
     that the user agent is checking to see if it can download the
     application.</p></li>

     <li><p>If these steps were invoked with a <a href="#cache-host">cache
     host</a>, and the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> is <i>downloading</i>, then also
     <a href="#queue-a-post-load-task">queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
     event</a> named <code title="event-appcache-downloading"><a href="#event-appcache-downloading">downloading</a></code> that is
     cancelable at the <code><a href="#applicationcache">ApplicationCache</a></code> singleton of that
     <a href="#cache-host">cache host</a>. The default action of this event must
     be, if the user agent <a href="#shows-caching-progress">shows caching progress</a>, the
     display of some sort of user interface indicating to the user the
     application is being downloaded.</p></li>

     <li><p>If the <a href="#concept-appcache-status" title="concept-appcache-status">status</a>
     of the <var title="">cache group</var> is either <i>checking</i>
     or <i>downloading</i>, then abort this instance of the
     <a href="#application-cache-download-process">application cache download process</a>, as an update is
     already in progress.</p></li>

     <li><p>Set the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> to <i>checking</i>.</p>

     </li><li><p>For each <a href="#cache-host">cache host</a> associated with an
     <a href="#application-cache">application cache</a> in <var title="">cache
     group</var>, <a href="#queue-a-post-load-task">queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a
     simple event</a> that is cancelable named <code title="event-appcache-checking"><a href="#event-appcache-checking">checking</a></code> at the
     <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
     host</a>. The default action of these events must be, if the
     user agent <a href="#shows-caching-progress">shows caching progress</a>, the display of
     some sort of user interface indicating to the user that the user
     agent is checking for the availability of updates.</p></li>

    </ol><p class="note">The remainder of the steps run asynchronously.</p>

    <p>If <var title="">cache group</var> already has an
    <a href="#application-cache">application cache</a> in it, then this is an <dfn id="concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade attempt</dfn>. Otherwise,
    this is a <dfn id="concept-appcache-cache" title="concept-appcache-cache">cache
    attempt</dfn>.</p>

   </li>

   <li><p>If this is a <a href="#concept-appcache-cache" title="concept-appcache-cache">cache
   attempt</a>, then this algorithm was invoked with a <a href="#cache-host">cache
   host</a>; <a href="#queue-a-post-load-task">queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a
   simple event</a> named <code title="event-appcache-checking"><a href="#event-appcache-checking">checking</a></code> that is cancelable
   at the <code><a href="#applicationcache">ApplicationCache</a></code> singleton of that <a href="#cache-host">cache
   host</a>. The default action of this event must be, if the user
   agent <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort
   of user interface indicating to the user that the user agent is
   checking for the availability of updates.</p></li>

   <li>

    <p><i>Fetching the manifest</i>: <a href="fetching-resources.html#fetch">Fetch</a> the resource
    from <var title="">manifest URL</var> with the <i>synchronous
    flag</i> set, and let <var title="">manifest</var> be that
    resource.</p> 
    <p>If the resource is labeled with the <a href="infrastructure.html#mime-type">MIME type</a>
    <code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code>, parse <var title="">manifest</var> according to the <a href="#parse-a-manifest" title="parse a
    manifest">rules for parsing manifests</a>, obtaining a list of
    <a href="#concept-appcache-explicit" title="concept-appcache-explicit">explicit entries</a>,
    <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entries</a>
    and the <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback
    namespaces</a> that map to them, entries for the <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a>,
    and a value for the <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
    wildcard flag</a>.</p>

   </li>

   <li>

    <p>If <i>fetching the manifest</i> fails due to a 404 or 410
    response <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or
    equivalent</a>, then run these substeps:</p>

    <ol><li><p>Mark <var title="">cache group</var> as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>. This <var title="">cache group</var> no longer exists for any purpose other
     than the processing of <code><a href="infrastructure.html#document">Document</a></code> objects already
     associated with an <a href="#application-cache">application cache</a> in the <var title="">cache group</var>.</p></li>

     <li><p>Let <var title="">task list</var> be an empty list of
     <a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>

     </li><li><p>For each <a href="#cache-host">cache host</a> associated with an
     <a href="#application-cache">application cache</a> in <var title="">cache
     group</var>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to
     <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <code title="event-appcache-obsolete"><a href="#event-appcache-obsolete">obsolete</a></code> that is
     cancelable at the <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the
     <a href="#cache-host">cache host</a>, and append it to <var title="">task
     list</var>. The default action of these events must be, if the
     user agent <a href="#shows-caching-progress">shows caching progress</a>, the display of
     some sort of user interface indicating to the user that the
     application is no longer available for offline use.</p></li>

     <li><p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
     entries</a>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a>
     to <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> that is cancelable named
     <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> (not <code title="event-appcache-obsolete"><a href="#event-appcache-obsolete">obsolete</a></code>!) at the
     <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
     host</a> the <code><a href="infrastructure.html#document">Document</a></code> for this entry, if there
     still is one, and append it to <var title="">task list</var>. The
     default action of this event must be, if the user agent
     <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
     user interface indicating to the user that the user agent failed
     to save the application for offline use.</p></li>

     <li><p>If <var title="">cache group</var> has an
     <a href="#application-cache">application cache</a> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
     <i>incomplete</i>, then discard that <a href="#application-cache">application
     cache</a>.</p>

     </li><li><p>If appropriate, remove any user interface indicating that
     an update for this cache is in progress.</p></li>

     <li><p>Let the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> be <i>idle</i>.</p></li>

     <li><p>For each <a href="webappapis.html#concept-task" title="concept-task">task</a> in <var title="">task list</var>, <a href="#queue-a-post-load-task" title="queue a post-load
     task">queue that task as a post-load task</a>.</p></li>

     <li><p>Abort the <a href="#application-cache-download-process">application cache download
     process</a>.</p></li>

    </ol></li>

   <li>

    <p>Otherwise, if <i>fetching the manifest</i> fails in some other
    way (e.g. the server returns another 4xx or 5xx response <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or equivalent</a>, or
    there is a DNS error, or the connection times out, or the user
    cancels the download, or the parser for manifests fails when
    checking the magic signature), or if the server returned a
    redirect, or if the resource is labeled with a <a href="infrastructure.html#mime-type">MIME
    type</a> other than <code><a href="iana.html#text-cache-manifest">text/cache-manifest</a></code>, then run
    the <a href="#cache-failure-steps">cache failure steps</a>.</p>

   </li>

   <li>

    <p>If this is an <a href="#concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade
    attempt</a> and the newly downloaded <var title="">manifest</var> is byte-for-byte identical to the manifest
    found in the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a>
    <a href="#application-cache">application cache</a> in <var title="">cache group</var>,
    or the server reported it as "304 Not Modified" <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or equivalent</a>, then
    run these substeps:</p>

    <ol><li><p>Let <var title="">cache</var> be the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> <a href="#application-cache">application
     cache</a> in <var title="">cache group</var>.</p></li>

     <li><p>Let <var title="">task list</var> be an empty list of
     <a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>

     </li><li>

      <p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
      entries</a>, wait for the resource for this entry to have
      either completely downloaded or failed.</p>

      <p>If the download failed (e.g. the connection times out, or the
      user cancels the download), then create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
      event</a> that is cancelable named <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> at the
      <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
      host</a> the <code><a href="infrastructure.html#document">Document</a></code> for this entry, if there
      still is one, and append it to <var title="">task list</var>. The
      default action of this event must be, if the user agent
      <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
      user interface indicating to the user that the user agent failed
      to save the application for offline use.</p>

      <p>Otherwise, associate the <code><a href="infrastructure.html#document">Document</a></code> for this entry
      with <var title="">cache</var>; store the resource for this
      entry in <var title="">cache</var>, if it isn't already there,
      and categorize its entry as a <a href="#concept-appcache-master" title="concept-appcache-master">master entry</a>. If the
      resource's <a href="urls.html#url">URL</a> has a <a href="urls.html#url-fragment" title="url-fragment">&lt;fragment&gt;</a> component, it must
      be removed from the entry in <var title="">cache</var>
      (application caches never include fragment identifiers).</p>

      <p class="note">HTTP caching rules, such as <code title="">Cache-Control: no-store</code>, are ignored for the
      purposes of the <a href="#application-cache-download-process">application cache download
      process</a>.</p>

     </li>

     <li><p>For each <a href="#cache-host">cache host</a> associated with an
     <a href="#application-cache">application cache</a> in <var title="">cache
     group</var>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to
     <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> that is cancelable named <code title="event-appcache-noupdate"><a href="#event-appcache-noupdate">noupdate</a></code> at the
     <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
     host</a>, and append it to <var title="">task list</var>. The
     default action of these events must be, if the user agent
     <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
     user interface indicating to the user that the application is up
     to date.</p></li>

     <li><p>Empty <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
     entries</a>.</p></li>

     <li><p>If appropriate, remove any user interface indicating that
     an update for this cache is in progress.</p></li>

     <li><p>Let the <a href="#concept-appcache-status" title="concept-appcache-status">status</a> of <var title="">cache group</var> be <i>idle</i>.</p></li>

     <li><p>For each <a href="webappapis.html#concept-task" title="concept-task">task</a> in <var title="">task list</var>, <a href="#queue-a-post-load-task" title="queue a post-load
     task">queue that task as a post-load task</a>.</p></li>

     <li><p>Abort the <a href="#application-cache-download-process">application cache download
     process</a>.</p></li>

    </ol></li>

   <li><p>Let <var title="">new cache</var> be a newly created
   <a href="#application-cache">application cache</a> in <var title="">cache
   group</var>. Set its <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> to
   <i>incomplete</i>.</p></li>

   <li><p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
   entries</a>, associate the <code><a href="infrastructure.html#document">Document</a></code> for this entry
   with <var title="">new cache</var>.</p></li>

   <li><p>Set the <a href="#concept-appcache-status" title="concept-appcache-status">status</a>
   of <var title="">cache group</var> to <i>downloading</i>.</p></li>

   <li><p>For each <a href="#cache-host">cache host</a> associated with an
   <a href="#application-cache">application cache</a> in <var title="">cache group</var>,
   <a href="#queue-a-post-load-task">queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
   event</a> that is cancelable named <code title="event-appcache-downloading"><a href="#event-appcache-downloading">downloading</a></code> at the
   <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
   host</a>. The default action of these events must be, if the
   user agent <a href="#shows-caching-progress">shows caching progress</a>, the display of some
   sort of user interface indicating to the user that a new version is
   being downloaded.</p></li>

   <li><p>Let <var title="">file list</var> be an empty list of
   URLs with flags.</p></li>

   <li><p>Add all the URLs in the list of <a href="#concept-appcache-explicit" title="concept-appcache-explicit">explicit entries</a> obtained
   by parsing <var title="">manifest</var> to <var title="">file
   list</var>, each flagged with "explicit entry".</p></li>

   <li><p>Add all the URLs in the list of <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entries</a> obtained
   by parsing <var title="">manifest</var> to <var title="">file
   list</var>, each flagged with "fallback entry".</p></li>

   <li><p>If this is an <a href="#concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade
   attempt</a>, then add all the URLs of <a href="#concept-appcache-master" title="concept-appcache-master">master entries</a> in the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> <a href="#application-cache">application
   cache</a> in <var title="">cache group</var> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
   <i>complete</i> to <var title="">file list</var>, each flagged with
   "master entry".</p></li>

   <li><p>If any URL is in <var title="">file list</var> more than
   once, then merge the entries into one entry for that URL, that
   entry having all the flags that the original entries had.</p></li>

   <li>

    <p>For each URL in <var title="">file list</var>, run the
    following steps. These steps may be run in parallel for two or
    more of the URLs at a time.</p>

    <ol><li>

      <p>If the resource URL being processed was flagged as neither an
      "explicit entry" nor or a "fallback entry", then the user agent
      may skip this URL.</p>

      <p class="note">This is intended to allow user agents to expire
      resources not listed in the manifest from the cache. Generally,
      implementors are urged to use an approach that expires
      lesser-used resources first.</p>

     </li>

     <li><p>For each <a href="#cache-host">cache host</a> associated with an
     <a href="#application-cache">application cache</a> in <var title="">cache
     group</var>, <a href="#queue-a-post-load-task">queue a post-load task</a> to fire an event
     with the name <code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>, which does not
     bubble, which is cancelable, and which uses the
     <code>ProgressEvent</code> interface, at the
     <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
     host</a>. The <code title="dom-ProgressEvents-lengthComputable">lengthComputable</code>
     attribute must be set to true, the <code title="dom-ProgressEvents-total">total</code> attribute must be
     set to the number of files in <var title="">file list</var>, and
     the <code title="dom-ProgressEvents-loaded">loaded</code>
     attribute must be set to the number of number of files in <var title="">file list</var> that have been either downloaded or
     skipped so far. The default action of these events must be, if
     the user agent <a href="#shows-caching-progress">shows caching progress</a>, the display
     of some sort of user interface indicating to the user that a file
     is being downloaded in preparation for updating the
     application. <a href="references.html#refsPROGRESS">[PROGRESS]</a></p></li>

     <li>

      <p><a href="fetching-resources.html#fetch">Fetch</a> the resource, from the <a href="origin-0.html#origin">origin</a>
      of the <a href="urls.html#url">URL</a> <var title="">manifest URL</var>, with
      the <i>synchronous flag</i> set and the <i>manual redirect
      flag</i> set. If this is an <a href="#concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade attempt</a>, then
      use the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a>
      <a href="#application-cache">application cache</a> in <var title="">cache
      group</var> as an HTTP cache, and honor HTTP caching semantics
      (such as expiration, ETags, and so forth) with respect to that
      cache. User agents may also have other caches in place that are
      also honored.</p> 

      <p class="note">If the resource in question is already being
      downloaded for other reasons then the existing download process
      can sometimes be used for the purposes of this step, as defined
      by the <a href="fetching-resources.html#fetch" title="fetch">fetching</a> algorithm.</p>

      <p class="example">An example of a resource that might already
      be being downloaded is a large image on a Web page that is being
      seen for the first time. The image would get downloaded to
      satisfy the <code><a href="embedded-content-1.html#the-img-element">img</a></code> element on the page, as well as
      being listed in the cache manifest. According to the rules for
      <a href="fetching-resources.html#fetch" title="fetch">fetching</a> that image only need be
      downloaded once, and it can be used both for the cache and for
      the rendered Web page.</p>

     </li>

     <li>

      <p>If the previous step fails (e.g. the server returns a 4xx or
      5xx response <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or
      equivalent</a>, or there is a DNS error, or the connection
      times out, or the user cancels the download), or if the server
      returned a redirect, then run the first appropriate step from
      the following list:</p>

      <dl class="switch"><dt>If the URL being processed was flagged as an "explicit
       entry" or a "fallback entry"</dt>

       <dd>

        <p>Run the <a href="#cache-failure-steps">cache failure steps</a>.</p>

        <p class="note">Redirects are fatal because they are either
        indicative of a network problem (e.g. a captive portal); or
        would allow resources to be added to the cache under URLs that
        differ from any URL that the networking model will allow
        access to, leaving orphan entries; or would allow resources to
        be stored under URLs different than their true URLs. All of
        these situations are bad.</p>

       </dd>

       <dt>If the error was a 404 or 410 HTTP response <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or equivalent</a></dt>

       <dd>

        <p>Skip this resource. It is dropped from the cache.</p>

       </dd>

       <dt>Otherwise</dt>

       <dd>

        <p>Copy the resource and its metadata from the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> <a href="#application-cache">application
        cache</a> in <var title="">cache group</var> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a>
        is <i>complete</i>, and act as if that was the fetched
        resource, ignoring the resource obtained from the network.</p>

       </dd>

      </dl><p>User agents may warn the user of these errors as an aid to
      development.</p>

      <p class="note">These rules make errors for resources listed in
      the manifest fatal, while making it possible for other resources
      to be removed from caches when they are removed from the server,
      without errors, and making non-manifest resources survive
      server-side errors.</p>

     </li>

     <li>

      <p>Otherwise, the fetching succeeded. Store the resource in
      the <var title="">new cache</var>.</p>

      <p>If the user agent is not able to store the resource (e.g.
      because of quota restrictions), the user agent may prompt the
      user or try to resolve the problem in some other manner (e.g.
      automatically pruning content in other caches). If the problem
      cannot be resolved, the user agent must run the <a href="#cache-failure-steps">cache
      failure steps</a>.</p>

     </li>

     <li><p>If the URL being processed was flagged as an "explicit
     entry" in <var title="">file list</var>, then categorize the
     entry as an <a href="#concept-appcache-explicit" title="concept-appcache-explicit">explicit
     entry</a>.</p></li>

     <li><p>If the URL being processed was flagged as a "fallback
     entry" in <var title="">file list</var>, then categorize the
     entry as a <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback
     entry</a>.</p></li>

     <li><p>If the URL being processed was flagged as an "master
     entry" in <var title="">file list</var>, then categorize the
     entry as a <a href="#concept-appcache-master" title="concept-appcache-master">master
     entry</a>.</p></li>

     <li><p>As an optimization, if the resource is an HTML or XML file
     whose root element is an <code><a href="semantics.html#the-html-element">html</a></code> element with a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute whose value
     doesn't match the manifest URL of the application cache being
     processed, then the user agent should mark the entry as being
     <a href="#concept-appcache-foreign" title="concept-appcache-foreign">foreign</a>.</p>

    </li></ol></li>

   <li><p>For each <a href="#cache-host">cache host</a> associated with an
   <a href="#application-cache">application cache</a> in <var title="">cache group</var>,
   <a href="#queue-a-post-load-task">queue a post-load task</a> to fire an event with the name
   <code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>, which does
   not bubble, which is cancelable, and which uses the
   <code>ProgressEvent</code> interface, at the
   <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
   host</a>. The <code title="dom-ProgressEvents-lengthComputable">lengthComputable</code>
   attribute must be set to true, the <code title="dom-ProgressEvents-total">total</code> and the <code title="dom-ProgressEvents-loaded">loaded</code> attributes must be
   set to the number of number of files in <var title="">file
   list</var>. The default action of these events must be, if the user
   agent <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort
   of user interface indicating to the user that all the files have
   been downloaded. <a href="references.html#refsPROGRESS">[PROGRESS]</a></p></li>

   <li><p>Store the list of <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespaces</a>,
   and the URLs of the <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entries</a> that they
   map to, in <var title="">new cache</var>.</p></li>

   <li><p>Store the URLs that form the new <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online whitelist</a> in
   <var title="">new cache</var>.</p></li>

   <li><p>Store the value of the new <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
   wildcard flag</a> in <var title="">new cache</var>.</p></li>

   <li>

    <p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
    entries</a>, wait for the resource for this entry to have
    either completely downloaded or failed.</p>

    <p>If the download failed (e.g. the connection times out, or the
    user cancels the download), then run these substeps:</p>

    <ol><li><p>Unassociate the <code><a href="infrastructure.html#document">Document</a></code> for this entry from
     <var title="">new cache</var>.</p></li>

     <li><p><a href="#queue-a-post-load-task">Queue a post-load task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
     event</a> that is cancelable named <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> at the
     <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the
     <code><a href="infrastructure.html#document">Document</a></code> for this entry, if there still is one. The
     default action of this event must be, if the user agent
     <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
     user interface indicating to the user that the user agent failed
     to save the application for offline use.</p>

     </li><li>

      <p>If this is a <a href="#concept-appcache-cache" title="concept-appcache-cache">cache
      attempt</a> and this entry is the last entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
      entries</a>, then run these further substeps:</p>

      <ol><li><p>Discard <var title="">cache group</var> and its only
       <a href="#application-cache">application cache</a>, <var title="">new
       cache</var>.</p>

       </li><li><p>If appropriate, remove any user interface indicating
       that an update for this cache is in progress.</p></li>

       <li><p>Abort the <a href="#application-cache-download-process">application cache download
       process</a>.</p></li>

      </ol></li>

     <li><p>Otherwise, remove this entry from <var title="">cache
     group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list
     of pending master entries</a>.</p></li>

    </ol><p>Otherwise, store the resource for this entry in <var title="">new cache</var>, if it isn't already there, and
    categorize its entry as a <a href="#concept-appcache-master" title="concept-appcache-master">master entry</a>.</p>

   </li>

   <li>

    <p><a href="fetching-resources.html#fetch">Fetch</a> the resource from <var title="">manifest
    URL</var> again, with the <i>synchronous flag</i> set, and let
    <var title="">second manifest</var> be that resource.</p> 
   </li>

   <li>

    <p>If the previous step failed for any reason, or if the fetching
    attempt involved a redirect, or if <var title="">second
    manifest</var> and <var title="">manifest</var> are not
    byte-for-byte identical, then schedule a rerun of the entire
    algorithm with the same parameters after a short delay, and run
    the <a href="#cache-failure-steps">cache failure steps</a>.</p>

   </li>

   <li>

    <p>Otherwise, store <var title="">manifest</var> in <var title="">new cache</var>, if it's not there already, and
    categorize its entry as <a href="#concept-appcache-manifest" title="concept-appcache-manifest">the manifest</a>.</p>

   </li>

   <li><p>Set the <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> of
   <var title="">new cache</var> to <i>complete</i>.</p></li>

   <li><p>Let <var title="">task list</var> be an empty list of <a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>

   </li><li>

    <p>If this is a <a href="#concept-appcache-cache" title="concept-appcache-cache">cache
    attempt</a>, then for each <a href="#cache-host">cache host</a> associated
    with an <a href="#application-cache">application cache</a> in <var title="">cache
    group</var>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to
    <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> that is cancelable named <code title="event-appcache-cached"><a href="#event-appcache-cached">cached</a></code> at the
    <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
    host</a>, and append it to <var title="">task list</var>. The
    default action of these events must be, if the user agent
    <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
    user interface indicating to the user that the application has
    been cached and that they can now use it offline.</p>

    <p>Otherwise, it is an <a href="#concept-appcache-upgrade" title="concept-appcache-upgrade">upgrade attempt</a>. For each
    <a href="#cache-host">cache host</a> associated with an <a href="#application-cache">application
    cache</a> in <var title="">cache group</var>, create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
    event</a> that is cancelable named <code title="event-appcache-updateready"><a href="#event-appcache-updateready">updateready</a></code> at the
    <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
    host</a>, and append it to <var title="">task list</var>. The
    default action of these events must be, if the user agent
    <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
    user interface indicating to the user that a new version is
    available and that they can activate it by reloading the page.</p>

   </li>

   <li><p>If appropriate, remove any user interface indicating that
   an update for this cache is in progress.</p></li>

   <li><p>Set the <a href="#concept-appcache-status" title="concept-appcache-status">update
   status</a> of <var title="">cache group</var> to
   <i>idle</i>.</p></li>

   <li><p>For each <a href="webappapis.html#concept-task" title="concept-task">task</a> in <var title="">task list</var>, <a href="#queue-a-post-load-task" title="queue a post-load
   task">queue that task as a post-load task</a>.</p></li>

  </ol><p>The <dfn id="cache-failure-steps">cache failure steps</dfn> are as follows:</p>

  <ol><li><p>Let <var title="">task list</var> be an empty list of <a href="webappapis.html#concept-task" title="concept-task">tasks</a>.</p>

   </li><li>

    <p>For each entry in <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
    entries</a>, run the following further substeps. These steps
    may be run in parallel for two or more entries at a time.</p>

    <ol><li><p>Wait for the resource for this entry to have either
     completely downloaded or failed.</p>

     </li><li><p>Unassociate the <code><a href="infrastructure.html#document">Document</a></code> for this entry from
     its <a href="#application-cache">application cache</a>, if it has one.</p></li>

     <li><p>Create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to
     <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> that is cancelable named <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> at the
     <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the
     <code><a href="infrastructure.html#document">Document</a></code> for this entry, if there still is one, and
     append it to <var title="">task list</var>. The default action of
     these events must be, if the user agent <a href="#shows-caching-progress">shows caching
     progress</a>, the display of some sort of user interface
     indicating to the user that the user agent failed to save the
     application for offline use.</p>

    </li></ol></li>

   <li><p>For each <a href="#cache-host">cache host</a> still associated with an
   <a href="#application-cache">application cache</a> in <var title="">cache group</var>,
   create a <a href="webappapis.html#concept-task" title="concept-task">task</a> to <a href="webappapis.html#fire-a-simple-event">fire a
   simple event</a> that is cancelable named <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code> at the
   <code><a href="#applicationcache">ApplicationCache</a></code> singleton of the <a href="#cache-host">cache
   host</a>, and append it to <var title="">task list</var>. The
   default action of these events must be, if the user agent
   <a href="#shows-caching-progress">shows caching progress</a>, the display of some sort of
   user interface indicating to the user that the user agent failed to
   save the application for offline use.</p></li>

   <li><p>Empty <var title="">cache group</var>'s <a href="#concept-appcache-pending-masters" title="concept-appcache-pending-masters">list of pending master
   entries</a>.</p></li>

   <li><p>If <var title="">cache group</var> has an <a href="#application-cache">application
   cache</a> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
   <i>incomplete</i>, then discard that <a href="#application-cache">application
   cache</a>.</p>

   </li><li><p>If appropriate, remove any user interface indicating that an
   update for this cache is in progress.</p></li>

   <li><p>Let the <a href="#concept-appcache-status" title="concept-appcache-status">status</a>
   of <var title="">cache group</var> be <i>idle</i>.</p></li>

   <li><p>If this was a <a href="#concept-appcache-cache" title="concept-appcache-cache">cache
   attempt</a>, discard <var title="">cache group</var>
   altogether.</p>

   </li><li><p>For each <a href="webappapis.html#concept-task" title="concept-task">task</a> in <var title="">task list</var>, <a href="#queue-a-post-load-task" title="queue a post-load
   task">queue that task as a post-load task</a>.</p></li>

   <li><p>Abort the <a href="#application-cache-download-process">application cache download
   process</a>.</p></li>

  </ol><p>Attempts to <a href="fetching-resources.html#fetch">fetch</a> resources as part of the
  <a href="#application-cache-download-process">application cache download process</a> may be done with
  cache-defeating semantics, to avoid problems with stale or
  inconsistent intermediary caches.</p>

  <hr><p>User agents may invoke the <a href="#application-cache-download-process">application cache download
  process</a>, in the background, for any <a href="#application-cache">application
  cache</a>, at any time (with no <a href="#cache-host">cache host</a>). This
  allows user agents to keep caches primed and to update caches even
  before the user visits a site.</p>

  <hr><p>Each <code><a href="infrastructure.html#document">Document</a></code> has a list of <dfn id="pending-application-cache-download-process-tasks">pending application
  cache download process tasks</dfn> that is used to delay events
  fired by the algorithm above until the document's <code title="event-load">load</code> event has fired. When the
  <code><a href="infrastructure.html#document">Document</a></code> is created, the list must be empty.</p>

  <p>When the steps above say to <dfn id="queue-a-post-load-task">queue a post-load task</dfn>
  <var title="">task</var>, where <var title="">task</var> is a <a href="webappapis.html#concept-task" title="concept-task">task</a> that dispatches an event on a
  target <code><a href="#applicationcache">ApplicationCache</a></code> object <var title="">target</var>, the user agent must run the appropriate steps
  from the following list:</p>

  <dl><dt>If <var title="">target</var>'s <code><a href="infrastructure.html#document">Document</a></code> is
   <a href="the-end.html#ready-for-post-load-tasks">ready for post-load tasks</a></dt>

   <dd><p><a href="webappapis.html#queue-a-task" title="queue a task">Queue</a> the task <var title="">task</var>.</p></dd>

   <dt>Otherwise</dt>

   <dd><p>Add <var title="">task</var> to <var title="">target</var>'s
   <code><a href="infrastructure.html#document">Document</a></code>'s list of <a href="#pending-application-cache-download-process-tasks">pending application cache
   download process tasks</a>.</p></dd>

  </dl><p>The <a href="webappapis.html#task-source">task source</a> for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the <a href="webappapis.html#networking-task-source">networking task
  source</a>.</p>




  <h4 id="the-application-cache-selection-algorithm"><span class="secno">5.6.5 </span>The application cache selection algorithm</h4>

  <p>When the <dfn id="concept-appcache-init" title="concept-appcache-init">application cache
  selection algorithm</dfn> algorithm is invoked with a
  <code><a href="infrastructure.html#document">Document</a></code> <var title="">document</var> and optionally a
  manifest <a href="urls.html#url">URL</a> <var title="">manifest URL</var>, the user
  agent must run the first applicable set of steps from the following
  list:</p>

  <dl class="switch"><dt>If there is a <var title="">manifest URL</var>, and <var title="">document</var> was loaded from an <a href="#application-cache">application
   cache</a>, and the URL of the <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> of that cache's
   <a href="#application-cache-group">application cache group</a> is <em>not</em> the same as
   <var title="">manifest URL</var></dt>

   <dd>

    <p>Mark the entry for the resource from which <var title="">document</var> was taken in the <a href="#application-cache">application
    cache</a> from which it was loaded as <a href="#concept-appcache-foreign" title="concept-appcache-foreign">foreign</a>.</p>

    <p>Restart the current navigation from the top of the <a href="history.html#navigate" title="navigate">navigation algorithm</a>, undoing any changes
    that were made as part of the initial load (changes can be avoided
    by ensuring that the step to <a href="history.html#update-the-session-history-with-the-new-page">update the session history with
    the new page</a> is only ever completed <em>after</em> this
    <a href="#concept-appcache-init" title="concept-appcache-init">application cache selection
    algorithm</a> is run, though this is not required).</p>

    <p class="note">The navigation will not result in the same
    resource being loaded, because "foreign" entries are never picked
    during navigation.</p>

    <p>User agents may notify the user of the inconsistency between
    the cache manifest and the document's own metadata, to aid in
    application development.</p>

   </dd>


   <dt>If <var title="">document</var> was loaded from an
   <a href="#application-cache">application cache</a>, and that <a href="#application-cache">application
   cache</a> still exists (it is not now <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>)</dt>

   <dd>

    <p>Associate <var title="">document</var> with the
    <a href="#application-cache">application cache</a> from which it was loaded. Invoke,
    in the background, the <a href="#application-cache-download-process">application cache download
    process</a> for that <a href="#application-cache">application cache</a>'s
    <a href="#application-cache-group">application cache group</a>, with <var title="">document</var> as the <a href="#cache-host">cache host</a>.</p>

   </dd>


   <dt>If <var title="">document</var>  was loaded using
   HTTP GET <a href="fetching-resources.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
   equivalent</a>, and, there is a <var title="">manifest
   URL</var>, and <var title="">manifest URL</var> has the <a href="origin-0.html#same-origin">same
   origin</a> as <var title="">document</var></dt>

   <dd>

    <p>Invoke, in the background, the <a href="#application-cache-download-process">application cache download
    process</a> for <var title="">manifest URL</var>, with <var title="">document</var> as the <a href="#cache-host">cache host</a> and with
    the resource from which <var title="">document</var> was parsed as
    the <a href="#concept-appcache-master" title="concept-appcache-master">master</a>
    resource.</p>

   </dd>


   <dt>Otherwise</dt> 
   <dd>

    <p>The <code><a href="infrastructure.html#document">Document</a></code> is not associated with any
    <a href="#application-cache">application cache</a>.</p>

    <p>If there was a <var title="">manifest URL</var>, the user agent
    may report to the user that it was ignored, to aid in application
    development.</p>

   </dd>

  </dl><h4 id="changesToNetworkingModel"><span class="secno">5.6.6 </span>Changes to the networking model</h4>

  <p>When a <a href="#cache-host">cache host</a> is associated with an
  <a href="#application-cache">application cache</a> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
  <i>complete</i>, any and all loads for resources related to that
  <a href="#cache-host">cache host</a> other than those for <a href="browsers.html#child-browsing-context" title="child
  browsing context">child browsing contexts</a> must go through the
  following steps instead of immediately invoking the mechanisms
  appropriate to that resource's scheme:</p>

  <ol><li><p>If the resource is not to be fetched using the HTTP GET
   mechanism <a href="fetching-resources.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
   equivalent</a>, or if its <a href="urls.html#url">URL</a> has a different <a href="urls.html#url-scheme" title="url-scheme">&lt;scheme&gt;</a> component than the
   <a href="#application-cache">application cache</a>'s <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a>, then
   <a href="fetching-resources.html#fetch">fetch</a> the resource normally and abort these
   steps.</p></li>

   <li><p>If the resource's URL is <a href="#concept-appcache-master" title="concept-appcache-master">a master entry</a>, <a href="#concept-appcache-manifest" title="concept-appcache-manifest">the manifest</a>, <a href="#concept-appcache-explicit" title="concept-appcache-explicit">an explicit entry</a>, or
   <a href="#concept-appcache-fallback" title="concept-appcache-fallback">a fallback entry</a> in
   the <a href="#application-cache">application cache</a>, then get the resource from the
   cache (instead of fetching it), and abort these steps.</p></li>

   <li><p>If there is an entry in the <a href="#application-cache">application cache</a>'s
   <a href="#concept-appcache-onlinewhitelist" title="concept-appcache-onlinewhitelist">online
   whitelist</a> that has the <a href="origin-0.html#same-origin">same origin</a> as the
   resource's URL and that is a <a href="infrastructure.html#prefix-match">prefix match</a> for the
   resource's URL, then <a href="fetching-resources.html#fetch">fetch</a> the resource normally and
   abort these steps.</p></li>

   <li>

    <p>If the resource's URL has the <a href="origin-0.html#same-origin">same origin</a> as the
    manifest's URL, and there is a <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>
    <var title="">f</var> in the <a href="#application-cache">application cache</a> that
    is a <a href="infrastructure.html#prefix-match">prefix match</a> for the resource's URL, then:</p>

    <p><a href="fetching-resources.html#fetch">Fetch</a> the resource normally. If this results in a
    redirect to a resource with another <a href="origin-0.html#origin">origin</a>
    (indicative of a captive portal), or a 4xx or 5xx status code
    <a href="fetching-resources.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or equivalent</a>,
    or if there were network errors (but not if the user canceled the
    download), then instead get, from the cache, the resource of the
    <a href="#concept-appcache-fallback" title="concept-appcache-fallback">fallback entry</a>
    corresponding to the <a href="#concept-appcache-fallback-ns" title="concept-appcache-fallback-ns">fallback namespace</a>
    <var title="">f</var>. Abort these steps.</p>

   </li>

   <li><p>If the <a href="#application-cache">application cache</a>'s <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online whitelist
   wildcard flag</a> is <i title="">open</i>, then
   <a href="fetching-resources.html#fetch">fetch</a> the resource normally and abort these
   steps.</p></li>

   <li><p>Fail the resource load as if there had been a generic
   network error.</p></li>

  </ol><p class="note">The above algorithm ensures that so long as the
  <a href="#concept-appcache-onlinewhitelist-wildcard" title="concept-appcache-onlinewhitelist-wildcard">online
  whitelist wildcard flag</a> is <i title="">blocking</i>,
  resources that are not present in the <a href="#concept-appcache-manifest" title="concept-appcache-manifest">manifest</a> will always fail
  to load (at least, after the <a href="#application-cache">application cache</a> has been
  primed the first time), making the testing of offline applications
  simpler.</p>

  </div><div class="impl">

  <h4 id="expiring-application-caches"><span class="secno">5.6.7 </span>Expiring application caches</h4>

  <p>As a general rule, user agents should not expire application
  caches, except on request from the user, or after having been left
  unused for an extended period of time.</p>

  <p>Application caches and cookies have similar implications with
  respect to privacy (e.g. if the site can identify the user when
  providing the cache, it can store data in the cache that can be used
  for cookie resurrection). Implementors are therefore encouraged to
  expose application caches in a manner related to HTTP cookies,
  allowing caches to be expunged together with cookies and other
  origin-specific data.</p>

  <p class="example">For example, a user agent could have a "delete
  site-specific data" feature that clears all cookies, application
  caches, local storage, databases, etc, from an origin all at
  once.</p>

  </div><div class="impl">

  <h4 id="disk-space"><span class="secno">5.6.8 </span>Disk space</h4>

  <p>User agents should consider applying constraints on disk usage of
  <a href="#application-cache" title="application cache">application caches</a>, and care
  should be taken to ensure that the restrictions cannot be easily
  worked around using subdomains.</p>

  <p>User agents should allow users to see how much space each domain
  is using, and may offer the user the ability to delete specific
  <a href="#application-cache" title="application cache">application caches</a>.</p>

  <p class="note">How quotas are presented to the user is not defined
  by this specification. User agents are encouraged to provide
  features such as allowing a user to indicate that certain sites are
  trusted to use more than the default quota, e.g. by asynchronously
  presenting a user interface while a cache is being updated, or by
  having an explicit whitelist in the user agent's configuration
  interface.</p>

  </div><h4 id="application-cache-api"><span class="secno">5.6.9 </span>Application cache API</h4><pre class="idl">interface <dfn id="applicationcache">ApplicationCache</dfn> {

  // <a href="#concept-appcache-status" title="concept-appcache-status">update status</a>
  const unsigned short <a href="#dom-appcache-uncached" title="dom-appcache-UNCACHED">UNCACHED</a> = 0;
  const unsigned short <a href="#dom-appcache-idle" title="dom-appcache-IDLE">IDLE</a> = 1;
  const unsigned short <a href="#dom-appcache-checking" title="dom-appcache-CHECKING">CHECKING</a> = 2;
  const unsigned short <a href="#dom-appcache-downloading" title="dom-appcache-DOWNLOADING">DOWNLOADING</a> = 3;
  const unsigned short <a href="#dom-appcache-updateready" title="dom-appcache-UPDATEREADY">UPDATEREADY</a> = 4;
  const unsigned short <a href="#dom-appcache-obsolete" title="dom-appcache-OBSOLETE">OBSOLETE</a> = 5;
  readonly attribute unsigned short <a href="#dom-appcache-status" title="dom-appcache-status">status</a>;

  // updates
  void <a href="#dom-appcache-update" title="dom-appcache-update">update</a>();
  void <a href="#dom-appcache-swapcache" title="dom-appcache-swapCache">swapCache</a>();

  // events
           attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onchecking" title="handler-appcache-onchecking">onchecking</a>;
           attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onerror" title="handler-appcache-onerror">onerror</a>;
           attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onnoupdate" title="handler-appcache-onnoupdate">onnoupdate</a>;
           attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-ondownloading" title="handler-appcache-ondownloading">ondownloading</a>;
           attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onprogress" title="handler-appcache-onprogress">onprogress</a>;
           attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onupdateready" title="handler-appcache-onupdateready">onupdateready</a>;
           attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-oncached" title="handler-appcache-oncached">oncached</a>;
           attribute <a href="webappapis.html#function">Function</a> <a href="#handler-appcache-onobsolete" title="handler-appcache-onobsolete">onobsolete</a>;
};
<a href="#applicationcache">ApplicationCache</a> implements <a href="infrastructure.html#eventtarget">EventTarget</a>;</pre><dl class="domintro"><dt><var title="">cache</var> = <var title="">window</var> . <code title="dom-applicationCache"><a href="#dom-applicationcache">applicationCache</a></code></dt>
   <dd>

    <p>(In a window.) Returns the <code><a href="#applicationcache">ApplicationCache</a></code> object that applies to the <a href="browsers.html#active-document">active document</a> of that <code><a href="browsers.html#window">Window</a></code>.</p>

   </dd>

   <dt><var title="">cache</var> = <var title="">self</var> . <code title="dom-applicationCache"><a href="#dom-applicationcache">applicationCache</a></code></dt>
   <dd>

    <p>(In a shared worker.) Returns the <code><a href="#applicationcache">ApplicationCache</a></code> object that applies to the current shared worker.
    
    <a href="references.html#refsWEBWORKERS">[WEBWORKERS]</a>
    
    </p>

   </dd>

   <dt><var title="">cache</var> . <code title="dom-appcache-status"><a href="#dom-appcache-status">status</a></code></dt>
   <dd>

    <p>Returns the current status of the application cache, as given by the constants defined below.</p>

   </dd>

   <dt><var title="">cache</var> . <code title="dom-appcache-update"><a href="#dom-appcache-update">update</a></code>()</dt>
   <dd>

    <p>Invokes the <a href="#application-cache-download-process">application cache download process</a>.</p>

    <p>Throws an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception if there is no application cache to update.</p>

   </dd>

   <dt><var title="">cache</var> . <code title="dom-appcache-swapCache"><a href="#dom-appcache-swapcache">swapCache</a></code>()</dt>
   <dd>

    <p>Switches to the most recent application cache, if there is a
    newer one. If there isn't, throws an
    <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>

    <p>This does not cause previously-loaded resources to be reloaded;
    for example, images do not suddenly get reloaded and style sheets
    and scripts do not get reparsed or reevaluated. The only change is
    that subsequent requests for cached resources will obtain the
    newer copies.</p>

   </dd>

  </dl><div class="impl">

  <p>There is a one-to-one mapping from <a href="#cache-host" title="cache host">cache
  hosts</a> to <code><a href="#applicationcache">ApplicationCache</a></code> objects. The <dfn id="dom-applicationcache" title="dom-applicationCache"><code>applicationCache</code></dfn>
  attribute on <code><a href="browsers.html#window">Window</a></code> objects must return the
  <code><a href="#applicationcache">ApplicationCache</a></code> object associated with the
  <code><a href="browsers.html#window">Window</a></code> object's <a href="browsers.html#active-document">active document</a>. The <dfn id="dom-sharedworkerglobalscope-applicationcache" title="dom-SharedWorkerGlobalScope-applicationCache"><code>applicationCache</code></dfn>
  attribute on <code>SharedWorkerGlobalScope</code> objects must
  return the <code><a href="#applicationcache">ApplicationCache</a></code> object associated with the
  worker.
  
  <a href="references.html#refsWEBWORKERS">[WEBWORKERS]</a>
  
  </p>

  <p class="note">A <code><a href="browsers.html#window">Window</a></code> or
  <code>SharedWorkerGlobalScope</code> object has an associated
  <code><a href="#applicationcache">ApplicationCache</a></code> object even if that <a href="#cache-host">cache
  host</a> has no actual <a href="#application-cache">application cache</a>.</p>

  <hr><p>The <dfn id="dom-appcache-status" title="dom-appcache-status"><code>status</code></dfn>
  attribute, on getting, must return the current state of the
  <a href="#application-cache">application cache</a> that the
  <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache host</a> is
  associated with, if any. This must be the appropriate value from the
  following list:</p>

  </div><dl><dt><dfn id="dom-appcache-uncached" title="dom-appcache-UNCACHED"><code>UNCACHED</code></dfn>
   (numeric value 0)</dt>

   <dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
   host</a> is not associated with an <a href="#application-cache">application
   cache</a> at this time.</p></dd>

   <dt><dfn id="dom-appcache-idle" title="dom-appcache-IDLE"><code>IDLE</code></dfn>
   (numeric value 1)</dt>

   <dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
   host</a> is associated with an <a href="#application-cache">application cache</a>
   whose <a href="#application-cache-group">application cache group</a>'s <a href="#concept-appcache-status" title="concept-appcache-status">update status</a> is
   <i>idle</i>, and that <a href="#application-cache">application cache</a> is the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> cache in its
   <a href="#application-cache-group">application cache group</a>, and the <a href="#application-cache-group">application
   cache group</a> is not marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>.</p></dd>

   <dt><dfn id="dom-appcache-checking" title="dom-appcache-CHECKING"><code>CHECKING</code></dfn>
   (numeric value 2)</dt>

   <dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
   host</a> is associated with an <a href="#application-cache">application cache</a>
   whose <a href="#application-cache-group">application cache group</a>'s <a href="#concept-appcache-status" title="concept-appcache-status">update status</a> is
   <i>checking</i>.</p></dd>

   <dt><dfn id="dom-appcache-downloading" title="dom-appcache-DOWNLOADING"><code>DOWNLOADING</code></dfn>
   (numeric value 3)</dt>

   <dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
   host</a> is associated with an <a href="#application-cache">application cache</a>
   whose <a href="#application-cache-group">application cache group</a>'s <a href="#concept-appcache-status" title="concept-appcache-status">update status</a> is
   <i>downloading</i>.</p></dd>

   <dt><dfn id="dom-appcache-updateready" title="dom-appcache-UPDATEREADY"><code>UPDATEREADY</code></dfn>
   (numeric value 4)</dt>

   <dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
   host</a> is associated with an <a href="#application-cache">application cache</a>
   whose <a href="#application-cache-group">application cache group</a>'s <a href="#concept-appcache-status" title="concept-appcache-status">update status</a> is
   <i>idle</i>, and whose <a href="#application-cache-group">application cache group</a> is not
   marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>,
   but that <a href="#application-cache">application cache</a> is <em>not</em> the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> cache in its
   group.</p></dd>

   <dt><dfn id="dom-appcache-obsolete" title="dom-appcache-OBSOLETE"><code>OBSOLETE</code></dfn>
   (numeric value 5)</dt>

   <dd><p>The <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache
   host</a> is associated with an <a href="#application-cache">application cache</a>
   whose <a href="#application-cache-group">application cache group</a> is marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>.</p></dd>

  </dl><div class="impl">

  <hr><p>If the <dfn id="dom-appcache-update" title="dom-appcache-update"><code>update()</code></dfn> method is
  invoked, the user agent must invoke the <a href="#application-cache-download-process">application cache
  download process</a>, in the background, for the <a href="#application-cache">application
  cache</a> with which the <code><a href="#applicationcache">ApplicationCache</a></code> object's
  <a href="#cache-host">cache host</a> is associated, but without giving that
  <a href="#cache-host">cache host</a> to the algorithm. If there is no such
  <a href="#application-cache">application cache</a>, or if it is marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>, then the method
  must raise an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception instead.</p>

  <p>If the <dfn id="dom-appcache-swapcache" title="dom-appcache-swapCache"><code>swapCache()</code></dfn> method
  is invoked, the user agent must run the following steps:

  </p><ol><li><p>Check that <code><a href="#applicationcache">ApplicationCache</a></code> object's
   <a href="#cache-host">cache host</a> is associated with an <a href="#application-cache">application
   cache</a>. If it is not, then raise an
   <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these
   steps.</p></li>

   <li><p>Let <var title="">cache</var> be the <a href="#application-cache">application
   cache</a> with which the <code><a href="#applicationcache">ApplicationCache</a></code> object's
   <a href="#cache-host">cache host</a> is associated. (By definition, this is the
   same as the one that was found in the previous step.)</p></li>

   <li><p>If <var title="">cache</var>'s <a href="#application-cache-group">application cache
   group</a> is marked as <a href="#concept-appcache-obsolete" title="concept-appcache-obsolete">obsolete</a>, then unassociate
   the <code><a href="#applicationcache">ApplicationCache</a></code> object's <a href="#cache-host">cache host</a>
   from <var title="">cache</var> and abort these steps. (Resources
   will now load from the network instead of the cache.)</p></li>

   <li><p>Check that there is an application cache in the same
   <a href="#application-cache-group">application cache group</a> as <var title="">cache</var>
   whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness
   flag</a> is <i>complete</i> and that is <a href="#concept-appcache-newer" title="concept-appcache-newer">newer</a> than <var title="">cache</var>. If there is not, then raise an
   <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these
   steps.</p></li>

   <li><p>Let <var title="">new cache</var> be the <a href="#concept-appcache-newer" title="concept-appcache-newer">newest</a> <a href="#application-cache">application
   cache</a> in the same <a href="#application-cache-group">application cache group</a> as
   <var title="">cache</var> whose <a href="#concept-appcache-completeness" title="concept-appcache-completeness">completeness flag</a> is
   <i>complete</i>.</p></li>

   <li><p>Unassociate the <code><a href="#applicationcache">ApplicationCache</a></code> object's
   <a href="#cache-host">cache host</a> from <var title="">cache</var> and instead
   associate it with <var title="">new cache</var>.</p></li>

  </ol><p>The following are the <a href="webappapis.html#event-handlers">event handlers</a> (and their
  corresponding <a href="webappapis.html#event-handler-event-type" title="event handler event type">event handler
  event types</a>) that must be supported, as IDL attributes, by
  all objects implementing the <code><a href="#applicationcache">ApplicationCache</a></code>
  interface:</p>

  <table><thead><tr><th><a href="webappapis.html#event-handlers" title="event handlers">Event handler</a> </th><th><a href="webappapis.html#event-handler-event-type">Event handler event type</a>
   </th></tr></thead><tbody><tr><td><dfn id="handler-appcache-onchecking" title="handler-appcache-onchecking"><code>onchecking</code></dfn> </td><td> <code title="event-appcache-checking"><a href="#event-appcache-checking">checking</a></code>
    </td></tr><tr><td><dfn id="handler-appcache-onerror" title="handler-appcache-onerror"><code>onerror</code></dfn> </td><td> <code title="event-appcache-error"><a href="#event-appcache-error">error</a></code>
    </td></tr><tr><td><dfn id="handler-appcache-onnoupdate" title="handler-appcache-onnoupdate"><code>onnoupdate</code></dfn> </td><td> <code title="event-appcache-noupdate"><a href="#event-appcache-noupdate">noupdate</a></code>
    </td></tr><tr><td><dfn id="handler-appcache-ondownloading" title="handler-appcache-ondownloading"><code>ondownloading</code></dfn> </td><td> <code title="event-appcache-downloading"><a href="#event-appcache-downloading">downloading</a></code>
    </td></tr><tr><td><dfn id="handler-appcache-onprogress" title="handler-appcache-onprogress"><code>onprogress</code></dfn> </td><td> <code title="event-appcache-progress"><a href="#event-appcache-progress">progress</a></code>
    </td></tr><tr><td><dfn id="handler-appcache-onupdateready" title="handler-appcache-onupdateready"><code>onupdateready</code></dfn> </td><td> <code title="event-appcache-updateready"><a href="#event-appcache-updateready">updateready</a></code>
    </td></tr><tr><td><dfn id="handler-appcache-oncached" title="handler-appcache-oncached"><code>oncached</code></dfn> </td><td> <code title="event-appcache-cached"><a href="#event-appcache-cached">cached</a></code>
    </td></tr><tr><td><dfn id="handler-appcache-onobsolete" title="handler-appcache-onobsolete"><code>onobsolete</code></dfn> </td><td> <code title="event-appcache-obsolete"><a href="#event-appcache-obsolete">obsolete</a></code>
  </td></tr></tbody></table></div><h4 id="browser-state"><span class="secno">5.6.10 </span>Browser state</h4><pre class="idl">[Supplemental, NoInterfaceObject]
interface <dfn id="navigatoronline">NavigatorOnLine</dfn> {
  readonly attribute boolean <a href="#dom-navigator-online" title="dom-navigator-onLine">onLine</a>;
};</pre><dl class="domintro"><dt><var title="">window</var> . <code title="dom-navigator"><a href="timers.html#dom-navigator">navigator</a></code> . <code title="dom-navigator-onLine"><a href="#dom-navigator-online">onLine</a></code></dt>

   <dd>

    <p>Returns false if the user agent is definitely offline
    (disconnected from the network). Returns true if the user agent
    might be online.</p>

    <p>The events <code title="event-online"><a href="#event-online">online</a></code> and <code title="event-offline"><a href="#event-offline">offline</a></code> are fired when the value of
    this attribute changes.</p>

   </dd>

  </dl><div class="impl">

  <p>The <dfn id="dom-navigator-online" title="dom-navigator-onLine"><code>navigator.onLine</code></dfn>
  attribute must return false if the user agent will not contact the
  network when the user follows links or when a script requests a
  remote page (or knows that such an attempt would fail), and must
  return true otherwise.</p>

  <p>When the value that would be returned by the <code title="dom-navigator-onLine"><a href="#dom-navigator-online">navigator.onLine</a></code> attribute of a
  <code><a href="browsers.html#window">Window</a></code> or <code>WorkerGlobalScope</code> changes from
  true to false, the user agent must <a href="webappapis.html#queue-a-task">queue a task</a> to
  <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <dfn id="event-offline" title="event-offline"><code>offline</code></dfn> at the
  <code><a href="browsers.html#window">Window</a></code> or <code>WorkerGlobalScope</code> object.</p>

  <p>On the other hand, when the value that would be returned by the
  <code title="dom-navigator-onLine"><a href="#dom-navigator-online">navigator.onLine</a></code> attribute
  of a <code><a href="browsers.html#window">Window</a></code> or <code>WorkerGlobalScope</code> changes
  from false to true, the user agent must <a href="webappapis.html#queue-a-task">queue a task</a> to
  <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <dfn id="event-online" title="event-online"><code>online</code></dfn> at the
  <code><a href="browsers.html#window">Window</a></code> or <code>WorkerGlobalScope</code> object.</p>

  <p>The <a href="webappapis.html#task-source">task source</a> for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the <a href="webappapis.html#networking-task-source">networking task
  source</a>.</p>

  </div><p class="note">This attribute is inherently unreliable. A computer
  can be connected to a network without having Internet access.</p><div class="example">

   <p>In this example, an indicator is updated as the browser goes
   online and offline.</p>

   <pre>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;title&gt;Online status&lt;/title&gt;
  &lt;script&gt;
   function updateIndicator() {
     document.getElementById('indicator').textContext = navigator.onLine ? 'online' : 'offline';
   }
  &lt;/script&gt;
 &lt;/head&gt;
 &lt;body onload="updateIndicator()" ononline="updateIndicator()" onoffline="updateIndicator()"&gt;
  &lt;p&gt;The network is: &lt;span id="indicator"&gt;(state unknown)&lt;/span&gt;
 &lt;/body&gt;
&lt;/html&gt;</pre>

  </div></body></html>