You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by José Ignacio París Prieto <jp...@sadiel.es> on 2004/05/19 10:50:32 UTC
CInclude caching in pipelines
Hello,
I,ve 2 questions about CInclude and caching:
- it seems to implement the CacheableProcessingComponent interface, in order
to support caching in a pipeline, but, looking through the code, the
"getKey" method ALWAYS RETURN "1" for all instances of the component. It's
supossed that the key returned must be unique for each different result of
the cinclude transformation. is that ok?
- moreover, this caching support is only activated if the parameter
"support-caching" is set to true (look at the setup method), which is not
documented.
Are those true or am I losing something? I'm pretending to support the
"If-modified-since" http header for pipelines. It works for those which
CInclude caching activated in that way, but I think that something is wrong
with the "1" key. wouldn't be better return the src URI in that method?
Regards
Jose
RE: CInclude caching in pipelines
Posted by Carsten Ziegeler <cz...@s-und-n.de>.
José Ignacio París Prieto wrote:
>
> Sorry for my misunderstanding :), but ...
No problem!
> does it means that the CInclude transformer isn't aware of
> changes of the included sources, and, consecuently, it
> doesn't report those changes to the pipeline component,
> returning the cached contents despite they are obsolete?
Yes, exactly. It is your (the application developers) responsibility
to take care of this fact. IF you know when your included
sources change, you can configure the caching for the
pipeline accordingly.
> If it does so, it means that the cinclude cache only
> refreshes when the expires period is over. is that ok?
Yes.
> In that case, i'd like to implement a cinclude-cache
> mechanism that is aware of modifications of the included
> sources. I suspect that IncludeCacheManager and Source have
> something to do there. Could anybody give me a clue?
Source is an abstraction of the included content, you can get
the contents from a source, some information and important
for caching, a SourceValidity object. This can be used
to test, if a cached response is valid or not.
For example if the source points to a file, the SourceValidity
contains the time stamp of the file to test if it has changed etc.
Now, the "only" thing you have to do is to collect all
SourceValidity objects of the included sources and return
them to the caching system (using the getValidity() method
of the cinclude transformer)
On the next invokation, you again collect these items
of the included sources, return them (by the transformer)
and the caching system tests if each source is still
valid. If one has changed, the pipeline is run again.
HTH
Carsten
> Thanks
>
> ----- Original Message -----
> From: "Carsten Ziegeler" <cz...@s-und-n.de>
> To: <de...@cocoon.apache.org>
> Sent: Wednesday, May 19, 2004 10:58 AM
> Subject: RE: CInclude caching in pipelines
>
>
> José Ignacio París Prieto wrote:
> >
> > Hello,
> > I,ve 2 questions about CInclude and caching:
> > - it seems to implement the CacheableProcessingComponent
> > interface, in order to support caching in a pipeline, but,
> > looking through the code, the "getKey" method ALWAYS RETURN
> > "1" for all instances of the component. It's supossed that
> > the key returned must be unique for each different result of
> > the cinclude transformation. is that ok?
> > - moreover, this caching support is only activated if the
> > parameter "support-caching" is set to true (look at the setup
> > method), which is not documented.
> > Are those true or am I losing something?
>
> Yes, they are true :)
> The caching algorithm checks if a cached response is valid
> based on the "input" of a pipeline component. The "input"
> of a component are e.g. parameters, the source that is read
> etc. But the component can rely on the fact that it always
> gets the same XML stream.
> So, in other words, the cinclude transformer has the same
> behaviour if the same XML comes into the transformer. The
> xml contains the same include statements etc. So, that's
> why the key is simply "1".
> For example, the file generator returns the source it reads
> as the key (the uri) because this is the "input" for the generator.
> It doesn't get any XML.
>
> Now, caching is only enabled if you set the parameter, yes,
> this is because of compatibility and because of ease-of-use.
> The caching has been introduced very lately, so if this
> would be the default behaviour some users would be surprised
> to see now changes even if they change the included sources etc.
> And this is of course also useful for highly dynamic includes,
> development and testing.
>
> HTH
> Carsten
>
> Carsten Ziegeler
> Open Source Group, S&N AG
> http://www.osoco.net/weblogs/rael/
> > I'm pretending to
> > support the "If-modified-since" http header for pipelines. It
> > works for those which CInclude caching activated in that way,
> > but I think that something is wrong with the "1" key.
> > wouldn't be better return the src URI in that method?
> >
> > Regards
> > Jose
> >
>
Re: CInclude caching in pipelines
Posted by José Ignacio París Prieto <jp...@sadiel.es>.
Sorry for my misunderstanding :), but ...
does it means that the CInclude transformer isn't aware of changes of the
included sources, and, consecuently, it doesn't report those changes to the
pipeline component, returning the cached contents despite they are obsolete?
If it does so, it means that the cinclude cache only refreshes when the
expires period is over. is that ok?
In that case, i'd like to implement a cinclude-cache mechanism that is aware
of modifications of the included sources. I suspect that IncludeCacheManager
and Source have something to do there. Could anybody give me a clue?
Thanks
----- Original Message -----
From: "Carsten Ziegeler" <cz...@s-und-n.de>
To: <de...@cocoon.apache.org>
Sent: Wednesday, May 19, 2004 10:58 AM
Subject: RE: CInclude caching in pipelines
José Ignacio París Prieto wrote:
>
> Hello,
> I,ve 2 questions about CInclude and caching:
> - it seems to implement the CacheableProcessingComponent
> interface, in order to support caching in a pipeline, but,
> looking through the code, the "getKey" method ALWAYS RETURN
> "1" for all instances of the component. It's supossed that
> the key returned must be unique for each different result of
> the cinclude transformation. is that ok?
> - moreover, this caching support is only activated if the
> parameter "support-caching" is set to true (look at the setup
> method), which is not documented.
> Are those true or am I losing something?
Yes, they are true :)
The caching algorithm checks if a cached response is valid
based on the "input" of a pipeline component. The "input"
of a component are e.g. parameters, the source that is read
etc. But the component can rely on the fact that it always
gets the same XML stream.
So, in other words, the cinclude transformer has the same
behaviour if the same XML comes into the transformer. The
xml contains the same include statements etc. So, that's
why the key is simply "1".
For example, the file generator returns the source it reads
as the key (the uri) because this is the "input" for the generator.
It doesn't get any XML.
Now, caching is only enabled if you set the parameter, yes,
this is because of compatibility and because of ease-of-use.
The caching has been introduced very lately, so if this
would be the default behaviour some users would be surprised
to see now changes even if they change the included sources etc.
And this is of course also useful for highly dynamic includes,
development and testing.
HTH
Carsten
Carsten Ziegeler
Open Source Group, S&N AG
http://www.osoco.net/weblogs/rael/
> I'm pretending to
> support the "If-modified-since" http header for pipelines. It
> works for those which CInclude caching activated in that way,
> but I think that something is wrong with the "1" key.
> wouldn't be better return the src URI in that method?
>
> Regards
> Jose
>
RE: CInclude caching in pipelines
Posted by Carsten Ziegeler <cz...@s-und-n.de>.
José Ignacio París Prieto wrote:
>
> Hello,
> I,ve 2 questions about CInclude and caching:
> - it seems to implement the CacheableProcessingComponent
> interface, in order to support caching in a pipeline, but,
> looking through the code, the "getKey" method ALWAYS RETURN
> "1" for all instances of the component. It's supossed that
> the key returned must be unique for each different result of
> the cinclude transformation. is that ok?
> - moreover, this caching support is only activated if the
> parameter "support-caching" is set to true (look at the setup
> method), which is not documented.
> Are those true or am I losing something?
Yes, they are true :)
The caching algorithm checks if a cached response is valid
based on the "input" of a pipeline component. The "input"
of a component are e.g. parameters, the source that is read
etc. But the component can rely on the fact that it always
gets the same XML stream.
So, in other words, the cinclude transformer has the same
behaviour if the same XML comes into the transformer. The
xml contains the same include statements etc. So, that's
why the key is simply "1".
For example, the file generator returns the source it reads
as the key (the uri) because this is the "input" for the generator.
It doesn't get any XML.
Now, caching is only enabled if you set the parameter, yes,
this is because of compatibility and because of ease-of-use.
The caching has been introduced very lately, so if this
would be the default behaviour some users would be surprised
to see now changes even if they change the included sources etc.
And this is of course also useful for highly dynamic includes,
development and testing.
HTH
Carsten
Carsten Ziegeler
Open Source Group, S&N AG
http://www.osoco.net/weblogs/rael/
> I'm pretending to
> support the "If-modified-since" http header for pipelines. It
> works for those which CInclude caching activated in that way,
> but I think that something is wrong with the "1" key.
> wouldn't be better return the src URI in that method?
>
> Regards
> Jose
>