Game Development Reference
In-Depth Information
fest. The name of the file, along with its extension, is completely arbitrary. By
convention, many developers named the manifest simply manifest.appcache ,
manifest (without an extension), or appcache.manifest . However, this file
could very well be named manifest.php?id=2642 , my-manifest-file.txt ,
or the_file.json .
An important thing to remember is that the manifest file be served with the proper
MIME type. If the browser attempts to fetch whatever file is listed in the manifest
attribute of the root HTML tag, and the MIME type is not text/cache-manifest ,
then the browser will reject the manifest, and no offline application cache will take
place.
There are many ways to set the MIME type to a file, but generally this is a server
setting. If using an Apache server, such as the one we are using with WAMP, MAMP,
or LAMP (see the online chapter, Setting Up the Environment ), we can easily do this
with a .htaccess file. For example, in the root directory of our project, we can cre-
ate a file named .htaccess containing the following code:
AddType text/cache-manifest .appcache
This would tell the server to add the right MIME type to any file with an extension
of .appcache . Of course, if you decide to tweak the htaccess file to serve the
cache-manifest MIME type to other file extensions, you could possibly run into is-
sues if the extension you choose is already associated with other MIME types (such
as .json ).
The first line of the manifest file must be the following string:
CACHE MANIFEST
If this line isn't present again, the entire API will take no effect. If there is as much as
an extra white space before the string listed above, the browser will throw the follow-
ing error, indicating that the file manifest is invalid, and nothing will be cached:
Application Cache Error event: Failed to parse
manifest
Search WWH ::




Custom Search