With everything that’s been discussed in this chapter on being a good mobile citizen, there’s still one piece that’s missing, the Holy Grail of web page apps: allowing users to play your game without any Internet access. Configured correctly, users with your game saved to their home screen can fire up your game while riding on the subway and kill aliens to their heart’s content. The secret to adding this capability to your game resides in configuring your game to correctly use the Application Cache, an HTML5 standard defined under Offline Web Applications.
The main crux of what’s necessary to make your app available offline consists of linking your HTML page to a manifest file by modifying the <html> tag at the beginning of your page as such:
<html lang="en" manifest="/manifest.appcache"> .. Rest of your HTML .. </html>
The name of the manifest file is actually up to you; however, the agreed-upon file suffix is .appcache and the file needs to be served with the mime-type of text/cache-manifest that is generally not preconfigured by Apache. You can add the following to your Apache config or to an .htaccess file to ensure the file is served correctly:
AddType text/cache-manifest .appcache
You generally want to explicitly override the expired header for the manifest.appcache file to prevent it from being cached. With mod_expires enabled in Apache, you can do this with the following declaration in either a ...