Joined: 20/01/2008 05:53:15
While developing an Ajax based application with the Mentawai framework I noticed that with the current version (1.14.1) it's not possible to cache Ajax requests on the client/browser side.
According to Steve Souders' High Performance Websites Ajax requests can and should be cached if possible.
Let's assume we have a shopping cart Ajax control. Every time the control is executed it also returns the date when the shopping cart was last modified through the Last-Modified HTTP response header. On the next request the browser sends the If-Modified-Since header along. The Ajax control can now compare these two dates and return a status code of 304 (Not Modified) if they are equal thus avoiding an unnecessary transmission of the possibly huge HTTP body.
Unfortunately in AjaxConsequence.java line 108 HttpUtils.disableCache(res); is executed which sets some HTTP headers that prevent the client from caching the Ajax requests (Cache-Control:no-cache etc). Hence the above scenario is currently not doable with Mentawai 1.14.1.
I suggest that in a future version of Mentawai the behaviour of the AjaxConsequence can be tweaked through an constructor parameter, e.g.
AjaxConsequence(String key, AjaxRenderer renderer, boolean pretty, boolean disableCaching)
By the way, what's up with Mentawai? It has been quite calm the last months, no new releases