<li><a href="#required_cookie">Cookies and the LocalServer</a></li>
<li><a href="#filesystem_location">Location of cached files</a></li>
</ol>
<h2 id="overview">Overview</h2>
<p>The LocalServer module is a specialized URL cache that the web application
controls. Requests for URLs in the LocalServer's cache are intercepted and
served locally from the user's disk.</p>
<p>Applications manage the cache using two classes:</p>
<ul>
<li><a href="#ResourceStore">ResourceStore</a> - for capturing ad-hoc URLs
using JavaScript. The ResourceStore allows an application to capture user data
files that need to be addressed with a URL, such as a PDF file or an
image.</li>
<li><a href="#ManagedResourceStore">ManagedResourceStore</a> - for capturing a
related set of URLs that are declared in a <em>manifest file</em>, and are
updated automatically. The ManagedResourceStore allows the set of resources
needed to run a web application to be captured.</li>
</ul>
<p>For both types of stores, the set of URLs captured is explicitly controlled by the web application.</p>
<h3>Serving and updating cached resources</h3>
<p>The LocalServer intercepts HTTP/HTTPS requests and serves them from the cache when all of these conditions are met:</p>
<ul>
<li>The URL is cached in a ResourceStore or ManagedResourceStore,</li>
<li>The store's <code>enabled</code> attribute is set to true, and </li>
<li>If the store has a <code>requiredCookie</code> attribute,
the request must have a cookie that matches. For further details read <a href="#required_cookie">Cookies and the LocalServer</a>.</li>
</ul>
<p>The LocalServer <em>always</em> serves a cached resource when the conditions are met, regardless of the network connection. The URLs contained in a store
are eligible for local serving without requiring the application to open the store.</p>
<p>To disable local serving of stored resources and force URLs to be served using the regular network connection, the application can set
the store's <code>enabled</code> attribute to false.</p>
<p>A key difference between the two types of stores is how resources are
updated. The contents of a ManagedResourceStore are automatically updated
periodically by Gears, even if the web developer never calls
<a href="#checkforupdate">checkForUpdate()</a>. For more information, see
<p>The LocalServer is a factory and container for the set of
ResourceStores and ManagedResourceStores your application creates and uses. Use resource stores to enable your JavaScript application to execute without a network connection. </p>
<p>To create a LocalServer object, use the Gears Factory as follows:</p>
The combination of name and requiredCookie (along with the domain) identify a unique store. <br />
Expected cookie format is "name=value". </td>
</tr>
<tr class="odd">
<td>Exceptions</td>
<td class="" >Throws a JavaScript exception if an errors occurs.</td>
</tr>
<tr class="odd">
<td>Description</td>
<td class="odd">Opens an existing ResourceStore or creates a new one if
no such store exists.<br />
<br />
If a requiredCookie is given, creates a ResourceStore that requires the cookie to be present in the client in order to serve the contents from the store.
<td><code>name</code> - string identifying the store. <br />
<code>requiredCookie</code> - optional.<br />
The combination of name and requiredCookie (along with the domain) identify a unique store. <br />
Expected cookie format is "name=value".</td>
</tr>
<tr class="odd">
<td>Exceptions</td>
<td class="" > Throws a JavaScript exception if an errors occurs. </td>
</tr>
<tr class="odd">
<td>Description</td>
<td class="odd">Opens an existing ResourceStore or returns null if no such store exists. If the store was originally created with a requiredCookie, the same value must be provided in order to open this ResourceStore.
<p>The ManagedResourceStore class is designed to cache a set of
inter-dependent resources. For example, it can cache the set of resources required
to bootstrap an application. The contents of a ManagedResourceStore are
determined by the URLs listed in a <a href="#manifest_file">manifest file</a>. When all resources listed
in the manifest have been captured, the LocalServer makes the set eligible
for use. Periodically, the LocalServer checks for an updated manifest file. If the manifest file has been updated, LocalServer automatically downloads the updated set of resources.</p>
<p>A ManagedResourceStore is a container of cached URLs. Each distinct ManagedResourceStore is uniquely identified by these attributes: </p>
<ul>
<li><code>name</code> - a string identifying the store.<br>
<i>Currently the name must consist only of visible ASCII characters excluding the following:</i>
<br><kbr>/ \ : * ? " < > | ; , </kbr><br>
<i>Before finalization of the API we expect to remove this restriction.</i></li>
<li><code>requiredCookie</code> - a cookie of the format "name=value" or null </li>
<li><code>origin</code> - the scheme, domain, and port of the current page.</li>
</ul>
<p> An application can have many <code>ManagedResourceStores</code>.</p>
<p>The ManagedResourceStores class requires a <em>manifest file</em> to define the URLs to store. The <a href="#manifest_file">manifest file</a> is described in detail, below. </p>
<h3>Attributes</h3>
<table>
<tr class="odd">
<th width="158">Attribute</th>
<th >Type</th>
<th >Description</th>
</tr>
<tr class="odd">
<td width="158"><strong>name</strong></td>
<td width="109" >readonly attribute string</td>
<td width="432" >The name of this managed resource store. </td>