Wednesday, March 21, 2012

JSP Data Caching

For static data generation, this means using the _jspInit() method to generate the content only once, and then calling it back up using _jspService(), rather than using out.print() every time the page is requested. Data generated with _jspInit() will last for the full lifetime of the servlet. You can cache dynamic data using one of the 5 state persistence mechanisms available in JSP - Tomcat's native session persistence mechanism, cookies, URL rewriting, hidden fields, or a JDBC-based session persistence mechanism of your own design. Of these, Tomcat's native session support is easily the highest performer (although it has trouble scaling), followed by hidden fields. A good solution to balance the load between client and server for scalable, secure caching is to use Tomcat's session persistence support to store secure data, and handle everything else with hidden fields.

No comments:

Post a Comment