Dynamic caching considerations with JSTL

WebSphere Commerce uses the Java Server Tag Library (JSTL) to create new JSP pages. If <% out.flush(); %> does not surround the <c:import> tag, using dynacache introduces strange behavior. The out.flush statement is required for all <c:import> statements, not just those for fragments. Even if the page is being cached using full-page caching, the out.flush tags are still required to surround the <c:import> tags.

When using the JSTL import tag, the JSPWriter buffers the data. It does not flush the data to the cache's writer. Because of this buffering, dynacache does not know when the application stopped writing the data to the parent writer. As a result, the child's content might also be cached as part of parent cache entry, and causes the child fragment to appear twice.

To prevent this problem, surround the <c:import> tags with <% out.flush(); %>. You flush the buffer before the import begins, and after it ends, to ensure that none of the child content is written to the parent's cache entry.