I am writing a Grails/GSP app that needs to be functional offline when no network is present. I read the following articles on HTML5 Offline/AppCache which were very informative:
To summarize (tl;dr
), I will need to define a manifest
attribute in each page's <html>
element like so:
<html manifest="myapp-cache.manifest">
...
</html>
Where myapp-cache.manifest
is the name of a "cache manifest" file that specifies offline/caching behaviors and might look like this:
CACHE MANIFEST
NETWORK:
*
CACHE:
index.html
somethingCool.html
myimage.png
myapp.css
The problem here is that, with Grails, I will have no HTML files to cache. In reality, I might have an index.gsp
and somethingCool.gsp
, but they represent pre-processed HTML and will never exist as HTML documents. And I can't specify GSPs in the cache manifest, because GSPs are (and shouldn't be) directly fetchable from the client-side.
Things get further complicated when we start reusing GSPs such as a header.gsp
and footer.gsp
, tag libs, and more.
So I ask: does Grails support HTML5 Offline? If so, how and in what capacity (where are the docs)? If not, is there anyway to coerce Grails to be Offline-compatible? Or is Grails incapable of this HTML5 feature?
Perhaps this could be accomplished somehow via URL mapping? For instance, perhaps there's a way to get Grails to map requests from, say, http://myapp.example.com/fizzbuzz.html
to http://myapp.example.com/fizzbuzz
, which would then prompt Grails to invoke the right controller action, and render the correct GSP?
Your statement "I will have no HTML files to cache" is wrong. Grails is a server side framework, and though you work with GSPs, tag libs and so on on the server side, all your client (the browser) sees is pure HTML.
As such it should be perfectly fine to cache .gsp, as all the browser will get and cache is the HTML that Grails delivers. Don't get confused by the extension! When offline, the browser will take the HTML from the AppCache same way as it would .html.
AppCache is a client side technology, as such I doubt there is any specific documentation for server side technology in general and Grails in particular, as it works the same for any server side technology.
@sneeb Grails can deliver content in whatever format you wish, HTML, JSON, XML and so on. As such Grails supports any type of content, including HTML5.