10.5.1 Servlet and JSP result caching
Servlet and JSP result caching intercepts calls to a servlet's service method, and checks whether the invocation can be served from cache. If the request cannot be served from cache, the servlet is invoked to generate the output that will be cached. The resulting cache entry contains the output and/or the side effects of the invocation, like calls to other servlets or JSP files. The figure below shows all steps if the output is not cached. If the output is cached, then steps 6, 7 and 8 are skipped.
The figure below gives a closer granularity look on steps 4 and 5. You can see that consequent requests are served only by the Web container, without involving the EJB container (steps 5 to 9).
Servlet and JSP result caching can be based on:
- Request parameters and attributes
- The URI used to invoke the servlet or JSP
- Session information
- Cookies
- Pathinfo and servlet path
- Http header and Request method
Servlet and JSP result caching can be used to cache both whole pages or fragments.