adam bien's blog

Configuring GlassFish To Serve Offline HTML 5 Applications 📎

HTML 5 Offline Applications have to specify a cache.manifest file, containing a list of resources to be cached in the browser. In addition this file has to be served with the text/cache-manifest Content-type.

GlassFish (v4.0.1 and older) does not serve the cache.manifest with the require content-type, so the browser will silently ignore to locally cache resources.

Fortunately, you can easily configure Glassfish editing the default-web.xml file in: glassfish4/glassfish/domains/[YOUR DOMAIN]/config

Add the following snippet:


 <mime-mapping>
    <extension>manifest</extension>
    <mime-type>text/cache-manifest</mime-type>
  </mime-mapping>

in the mime-mapping section (e.g. after the line 1169) and restart GlassFish. Now you can shutdown the internet :-)

See you at Java EE Workshops at MUC Airport and particularly at Java EE 7 User Interfaces Workshop. We will discuss the fusion of JavaEE 7 with HTML 5 …and JavaFX.