You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ugo Cei <ug...@apache.org> on 2005/05/30 16:44:51 UTC

mod_cache and Content-length

Hi,

I was reading the ControllingModCache wiki page [1] and it says:

"To generate Content-length, you must currently create your own 
serializer, to set the buffering flag, as it is not yet configurable."

And indeed, there's no way to configure generation of content-length 
header in AbstractTextSerializer without overriding the 
shouldSetContentLenght() method in a subclass.

Is there any particular reason why this has not been made configurable, 
or is it just that nobody has had this particular itch to scratch yet? 
In the latter case, I'd like to scratch it myself, if no one objects.

	Ugo

[1] http://wiki.apache.org/cocoon/ControllingModCache

-- 
Ugo Cei
Tech Blog: http://agylen.com/
Source.zone: http://sourcezone.info/
Wine & Food Blog: http://www.divinocibo.it/

Re: mod_cache and Content-length

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 30 mai 05, à 16:44, Ugo Cei a écrit :

> ....And indeed, there's no way to configure generation of 
> content-length header in AbstractTextSerializer without overriding the 
> shouldSetContentLenght() method in a subclass.
>
> Is there any particular reason why this has not been made 
> configurable, or is it just that nobody has had this particular itch 
> to scratch yet? In the latter case, I'd like to scratch it myself, if 
> no one objects...

As long as you keep the current behavior with the default value, no one 
can complain I guess.

Also, it would be good to put a warning next to the configuration 
option: activating this causes (IIUC) the serializer to buffer the 
whole output before sending it, which can make a big 
performance/resources difference.

-Bertrand

Re: mod_cache and Content-length

Posted by Pier Fumagalli <pi...@betaversion.org>.
On 1 Jun 2005, at 06:25, Bertrand Delacretaz wrote:

> Le 31 mai 05, à 23:12, Pier Fumagalli a écrit :
>
>> ...Erm... Apache caches also without "Content-Length" (it actually  
>> calculates that for you)... In production, this is my  
>> configuration:..
>>
>
> Do you know which of these options cause this behaviour, or is is  
> by default?
> That's not what I saw in my tests, but this was a while ago so it  
> might have changed in newer releases of mod_cache.

It's on by default... The only thing I add to my pages in Cocoon are  
these two headers:

Expires: Wed, 01 Jun 2005 13:07:31 GMT
Cache-Control: max-age=600

But even without those, with these:

> CacheDefaultExpire 600
> CacheIgnoreCacheControl On
> CacheIgnoreNoLastMod On

(Especially CacheIgnoreNoLastMod) it will cache for 600 seconds...

     Pier

Re: mod_cache and Content-length

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 31 mai 05, à 23:12, Pier Fumagalli a écrit :
> ...Erm... Apache caches also without "Content-Length" (it actually 
> calculates that for you)... In production, this is my configuration:..

Do you know which of these options cause this behaviour, or is is by 
default?
That's not what I saw in my tests, but this was a while ago so it might 
have changed in newer releases of mod_cache.

-Bertrand

> CacheMaxExpire 1800
> CacheRoot /opt/apache/var/cache
> CacheSize 1048576
> CacheMinFileSize 1
> CacheMaxFileSize 524288
> CacheDirLevels 5
> CacheDirLength 3
> CacheDefaultExpire 600
> CacheIgnoreCacheControl On
> CacheIgnoreNoLastMod On
>
> CacheEnable disk /
> CacheDisable /search
> CacheDisable /images
> CacheDisable /includes

Re: mod_cache and Content-length

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 31/mag/05, alle 23:12, Pier Fumagalli ha scritto:

> Erm... Apache caches also without "Content-Length" (it actually 
> calculates that for you)... In production, this is my configuration:

Thanks, but after some trial & error I got it to cache when Cocoon 
outputs the header, so for now I'm set.

	Ugo

-- 
Ugo Cei
Tech Blog: http://agylen.com/
Source.zone: http://sourcezone.info/
Wine & Food Blog: http://www.divinocibo.it/

Re: mod_cache and Content-length

Posted by Pier Fumagalli <pi...@betaversion.org>.
On 30 May 2005, at 15:44, Ugo Cei wrote:

> Hi,
>
> I was reading the ControllingModCache wiki page [1] and it says:
>
> "To generate Content-length, you must currently create your own  
> serializer, to set the buffering flag, as it is not yet configurable."
>
> And indeed, there's no way to configure generation of content- 
> length header in AbstractTextSerializer without overriding the  
> shouldSetContentLenght() method in a subclass.
>
> Is there any particular reason why this has not been made  
> configurable, or is it just that nobody has had this particular  
> itch to scratch yet? In the latter case, I'd like to scratch it  
> myself, if no one objects.
>
>     Ugo
>
> [1] http://wiki.apache.org/cocoon/ControllingModCache

Erm... Apache caches also without "Content-Length" (it actually  
calculates that for you)... In production, this is my configuration:

CacheMaxExpire 1800
CacheRoot /opt/apache/var/cache
CacheSize 1048576
CacheMinFileSize 1
CacheMaxFileSize 524288
CacheDirLevels 5
CacheDirLength 3
CacheDefaultExpire 600
CacheIgnoreCacheControl On
CacheIgnoreNoLastMod On

CacheEnable disk /
CacheDisable /search
CacheDisable /images
CacheDisable /includes

     Pier



Re: mod_cache and Content-length

Posted by Carsten Ziegeler <cz...@apache.org>.
Ugo Cei wrote:
> Il giorno 30/mag/05, alle 19:19, Carsten Ziegeler ha scritto:
> 
> 
>>I can have a look at it in the next days if you want.
> 
> 
> Would be great.
> 
Done.

The content length is now set, if the pipeline buffers the whole
contents; I have only done some minor tests, but I think there
shouldn't be any side effects.

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

Re: mod_cache and Content-length

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 30/mag/05, alle 19:19, Carsten Ziegeler ha scritto:

> I can have a look at it in the next days if you want.

Would be great.

	Ugo

-- 
Ugo Cei
Tech Blog: http://agylen.com/
Source.zone: http://sourcezone.info/
Wine & Food Blog: http://www.divinocibo.it/

Re: mod_cache and Content-length

Posted by Carsten Ziegeler <cz...@apache.org>.
Ugo Cei wrote:
> Il giorno 30/mag/05, alle 16:57, Bertrand Delacretaz ha scritto:
> 
> 
>>Le 30 mai 05, à 16:53, Carsten Ziegeler a écrit :
>>
>>>...So, we could also *always* set the content length if the pipeline
>>>buffers by itself. WDYT?..
>>
>>Didn't know about that, but it makes sense as we get Content-Length 
>>for free then.
>>
>>Ugo, I hope you'll also write tests if you implement this, it's real 
>>easy with the new HmltUnit-based framework ;-)
> 
> 
> Well, I could go the easy route and add a configurable parameter. That 
> would be a piece of cake.
> 
> Or I could follow Carsten's suggestion, but for that I need to deepen 
> my knowledge of pipeline machinery.
> 
> I'll see if I can find some time to do it the right way.
> 
I can have a look at it in the next days if you want.

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

Re: mod_cache and Content-length

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 30/mag/05, alle 16:57, Bertrand Delacretaz ha scritto:

> Le 30 mai 05, à 16:53, Carsten Ziegeler a écrit :
>> ...So, we could also *always* set the content length if the pipeline
>> buffers by itself. WDYT?..
>
> Didn't know about that, but it makes sense as we get Content-Length 
> for free then.
>
> Ugo, I hope you'll also write tests if you implement this, it's real 
> easy with the new HmltUnit-based framework ;-)

Well, I could go the easy route and add a configurable parameter. That 
would be a piece of cake.

Or I could follow Carsten's suggestion, but for that I need to deepen 
my knowledge of pipeline machinery.

I'll see if I can find some time to do it the right way.

	Ugo

-- 
Ugo Cei
Tech Blog: http://agylen.com/
Source.zone: http://sourcezone.info/
Wine & Food Blog: http://www.divinocibo.it/

Re: mod_cache and Content-length

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 30 mai 05, à 16:53, Carsten Ziegeler a écrit :
> ...So, we could also *always* set the content length if the pipeline
> buffers by itself. WDYT?..

Didn't know about that, but it makes sense as we get Content-Length for 
free then.

Ugo, I hope you'll also write tests if you implement this, it's real 
easy with the new HmltUnit-based framework ;-)

-Bertrand

Re: mod_cache and Content-length

Posted by Carsten Ziegeler <cz...@apache.org>.
Ugo Cei wrote:
> Hi,
> 
> I was reading the ControllingModCache wiki page [1] and it says:
> 
> "To generate Content-length, you must currently create your own 
> serializer, to set the buffering flag, as it is not yet configurable."
> 
> And indeed, there's no way to configure generation of content-length 
> header in AbstractTextSerializer without overriding the 
> shouldSetContentLenght() method in a subclass.
> 
> Is there any particular reason why this has not been made configurable, 
> or is it just that nobody has had this particular itch to scratch yet? 
> In the latter case, I'd like to scratch it myself, if no one objects.
> 
This is one way of doing it - the other one is using the "buffering" of
the pipeline. By default, the whole content of a pipeline is first
"cached" in memory and only on success written to the output stream.
This prevents corrupt output if an error occurs during processing and
the handle-errors part is invoked.
So, we could also *always* set the content length if the pipeline
buffers by itself. WDYT?

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/