You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2007/01/29 11:10:56 UTC

Not caching pages with continuations (was:...where is 304?)

On 1/29/07, Ard Schrijvers <a....@hippo.nl> wrote:

> For high-traffic sites, we obviously want to use mod_cache, but, at the same time,
> mod_cache shouldn't cache pages with a continuation in it....

The problem is making the HTTP cache headers variable according to
which pipeline is executed.

But, in principle, you have to set the headers before any content is
written to the output, and at this point you might not know what kind
of caching you need.

The way I've been solving this is a follows:

a) In pipelines, actions or flowscript set request attributes to
indicate what type of caching is needed

b) A custom transformer at the end of the pipeline sets the HTTP cache
headers according to these request attributes

Now, you're not supposed to set headers at the end of the pipeline,
but anyway the serializer has to buffer the content to be able to set
the Content-Length header. So nothing is actually written to the
output before b) *if* the serializer returns true for
shouldSetContentType.

https://issues.apache.org/jira/browse/COCOON-1619 also plays a role in
this, as headers set by internal pipelines are ignored.

Not sure if this solution can be defined as a best practice, as it's a
bit of a hack...but if works for me ;-)

-Bertrand