Using Ajax components in a web page can make slow the performance of your web pages as they load resources over the network and as a page is rendered by the browser.
A solution is needed that will improve both the network performance and browser loading of Ajax based applications
jMaki was designed to manage the rendering of Ajax resources and has been modified as of jMaki 1.8 to do the following:
Here are some under the hood details on what jMaki does to improve the performance.
Widget names are aggregated for a given page and used to generate MD5 hashes representing all the
jMaki can automatically load a minified
component-min.js in place of
It is still the developers responsibility to generate the minified resource. There are many tools for minifiying code which include Dojo ShrinkSafe, Dean Edwards Packer, and Yahoo Compressor.
Max Age Header
You will need to have version 1.8 of better of jMaki to use this feature. Currently we only provide this for PHP / JSP /JSF. Get the latest jMaki from the downloads page.
SetupIn PHP you will need to create a "cache" directory in the same directory as your
jMaki.php. The permissions on the cache directory must be set such that the process running PHP can write files to the cache directory. You also need to make sure that the Cache.php file is located in the same directory as your
Enabling Combined Resources
Configuration of the performance options is done by modifying the
following variables that appear at the top of the in the
|combineStyles||Combine all CSS resources.||false|
|combineResourcesMaxAge||Max age to keep content in seconds.||345,600|
Further customization could be done by modfiying the Cache.php which manages the chached content.
In Java a servlet needs to be configured in your web.xml file to serve cached resources which are kept in memory. The servlet class is included in the jmaki library is:
You will need to add the servlet mapping should be:
If you use a servlet mapping other than the one above you will need to configure the jMaki runtime with the new location.
Enabling Combined Resources
Configuration of the performance options in Java is done by modifying the following context parameters in the web.xml:
|jmaki-combined-resources-service||URL mapping to the Serlvet that renders the cached content.||/cr|
|jmaki-combinestyles||Combine all CSS resources.||false|
|jmaki-combined-resources-maxage||Max age to keep content in seconds.||345,600|
The cached content is stored in the Servlet context and is flushed when an application is re-deployed.
The following snippet is the minimal set of things you need in your web.xml.
<context-param> <param-name>jmaki-combinescripts</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>jmaki-combinestyles</param-name> <param-value>true</param-value> </context-param> <servlet> <servlet-name>Combined Resource Servlet</servlet-name> <servlet-class>jmaki.runtime.CombinedResourceServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Combined Resource Servlet</servlet-name> <url-pattern>/cr</url-pattern> </servlet-mapping>
If you have any problems or issues with the caching please direct questions to the jMaki Forums.
Yahoo has provided a great set of guidelines and client tooling for analyzing performance issues. See the Yahoo Performance page for more details and resources.