Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIApplicationCache

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!

This interface represents an application cache, which stores resources for offline use.
1.0
28
Introduced
Gecko 1.9.1
Inherits from: nsISupports Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

Each application cache has a unique client ID for use with nsICacheService.openSession() method, to access the cache's entries.

Each entry in the cache can be marked with a set of types, specified in the Constants section.

All application caches with the same group ID belong to a cache group. Each group has one "active" cache that will service future loads. Inactive caches are removed from the cache when no longer referenced.

Method overview

void activate();
void addNamespaces(in nsIArray namespaces);
void discard();
void gatherEntries(in PRUint32 typeBits, out unsigned long count, [array, size_is(count)] out string keys);
nsIApplicationCacheNamespace getMatchingNamespace(in ACString key);
unsigned long getTypes(in ACString key);
void initAsHandle(in ACString groupId, in ACString clientId);
void markEntry(in ACString key, in unsigned long typeBits);
void unmarkEntry(in ACString key, in unsigned long typeBits);

Attributes

Attribute Type Description
active boolean true if the cache is the active cache for this group, otherwise false. Read only.
clientID ACString The client ID for this application cache. Clients can open a session with nsICacheService.createSession() using this client ID and a storage policy of STORE_OFFLINE to access this cache. Read only.
groupID ACString The group ID for this cache group. This is the URI of the cache manifest file. Read only.
usage unsigned long The disk usage of the application cache, in bytes. Read only.

Constants

Constant Value Description
ITEM_MANIFEST 1 This item is the application manifest.
ITEM_EXPLICIT 2 This item was explicitly listed in the application manifest.
ITEM_IMPLICIT 4 This item was navigated to in a top level browsing context, and named this cache's group as its manifest.
ITEM_DYNAMIC 8 This item was added to the cache using the dynamic scripting API.
ITEM_FOREIGN 16 This item was listed in the application manifest, but named a different cache group as its manifest.
ITEM_FALLBACK 32 This item was listed as a fallback entry.
ITEM_OPPORTUNISTIC 64 This item matched an opportunistic cache namespace and was cached for that reason.

Methods

activate()

Makes this cache the active application cache for this group. Future loads associated with this group will come from this cache. Other caches from this cache group will be deactivated.

void activate();
Parameters

None.

addNamespaces()

Add a set of namespace entries to the application cache.

void addNamespaces(
  in nsIArray namespaces
);
Parameters
namespaces
An nsIArray of nsIApplicationCacheNamespace objects describing the namespaces to add to the cache.

discard()

Discards this application cache. This removes all resources it has cached. If this is the active application cache for the group, the group is removed.

void discard();
Parameters

None.

gatherEntries()

Returns a list of entries in the cache whose type matches one or more of the specified types.

void gatherEntries(
  in PRUint32 typeBits,
  out unsigned long count,
  [array, size_is(count)] out string keys
);
Parameters
typeBits
A bit field indicating the types against which to match. See Constants for a list of types.
count
On return, indicates how many matching entries were found.
keys
An array of the keys matching one or more of the types indicated by typeBits.

getMatchingNamespace()

Returns the most specific namespace matching a given key.

nsIApplicationCacheNamespace getMatchingNamespace(
  in ACString key
);
Parameters
key
The key for the cache entry whose most specific namespace is to be returned.
Return value

An nsIApplicationCacheNamespace object describing the most specific namespace matching the given key.

getTypes()

Gets the types for a given entry in the cache.

unsigned long getTypes(
  in ACString key
);
Parameters
key
The key for the cache entry whose types you wish to retrieve.
Return value

A bit field indicating the entry's types. See Constants for a list of types.

Requires Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

initAsHandle()

Init this application cache instance to just hold the group ID and the client ID to work just as a handle to the real cache. Used on content process to simplify the application cache code.

void initAsHandle(
  in ACString groupId,
  in ACString clientId
);
Parameters
groupId
Missing Description
clientId
Missing Description

markEntry()

Adds item types to a given entry.

void markEntry(
  in ACString key,
  in unsigned long typeBits
);
Parameters
key
The key for the cache entry to which to add types.
typeBits
A bit field indicating the types to add to the entry. See Constants for a list of types.

unmarkEntry()

Removes types from a given entry. If the resulting entry has no types left, the entry is removed.

void unmarkEntry(
  in ACString key,
  in unsigned long typeBits
);
Parameters
key
The key for the cache entry from which to remove types.
typeBits
A bit field indicating the types to remove from the entry. See Constants for a list of types.

See also

文档标签和贡献者

 此页面的贡献者: Sheppy, trevorh, Jürgen Jeka
 最后编辑者: Sheppy,