HTML and CSS Reference
the domain name for your distribution in the properties. Any file you upload to your bucket is available under
that domain name and served up lightning quick.
You can copy files up manually to S3 using the management console, but there are numerous tools and lib-
Nonimage and script resources (meaning data resources such as .json level data and CSVs) are generally
loaded via Ajax, which has a same origin policy. The same origin policy requires that you load assets from
the same domain/subdomain, protocol, and port as your main HTML script was loaded from. This isn't a
something to keep in mind.
Going Offline Completely with Application
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
Creating Your Manifest File
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 ..
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 precon-
figured 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 config file or an .htaccess file:
ExpiresByType text/cache-manifest "access plus 0 minutes"
Next, you need to actually write the cache manifest file. This is actually a fairly simple text document that
starts with the uppercase words " CACHE MANIFEST " and follows with up to three different sections:
• CACHE : For files that should be cached.
• NETWORK : For resources that should be available only when online.