The
ResponseCache
is used to cache responses generated using the
WebloungeResponse
object. It's implementation makes sure that the response that is handed over in the first place is tweaked (wrapped) in a way that the output that is written to it is streamed to the cache as well as to the client.
The structure of the response cache is hierarchical in that there is a general response, consisting of stacked response parts. This supports content structures that have different lifetimes, e. g. a page might become invalid but some pieces on it live much longer. When a client requests that invalidated page, the output renderer needs to produce the enclosing content (template) from scratch but could choose to reuse the cached pieces.
The two methods {@link #startResponse(CacheTag[],WebloungeRequest,WebloungeResponse,long,long)}and {@link #startResponsePart(CacheTag[],HttpServletResponse,long,long)}are used to create an entry in the cache. They will return null
if the entry is already present, meaning that the cached version will be sent to the client. If a CacheHandle
is returned, then a new cache entry, identified by the handle, was created and the output written to the response will be sent to both the cache and the client.
Note that in order to take advantage of the cache, it is crucial that you tag your responses and their parts in a useful manner.