Page Streaming
The FlexCache also supports optional page output streaming. Page streaming means that output is written to the stream as soon as it becomes available, thus enabling the client to see some results of the page before the whole page is completely rendered. However, in a template environment like OpenCms, this has some drawbacks because the application is not able to send headers, redirects or cookies after the first byte of the response has been written to the stream. This is a limitation of the HTML protocol. Therefore it is usually beneficial to buffer the whole page before writing the results to the output stream, in this case headers etc. can be collected and written to the stream together before the HTML output.
The FlexCache allows you to choose from these two models on a per-page basis. It supports an OpenCms file property called stream
which is attached to a resource exactly like the cache properties. The default is set to false
, i.e. streaming is disabled. You can set stream
to true
to enable streaming for this particular page. This can be useful if you know that no redirects etc. will be set on the page and the page output is quite long.
Please note: A JSP in OpenCms will always be buffered (i.e. not streamed) if it is calculated dynamically, even if the stream
property is set to true. This is because of the internals of the FlexCache implementation. However, setting stream
to true
is still useful on a JSP because if the page gets cached, the cached entry will be streamed on the next request to the page.