You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Manuel Lemos <ml...@acm.org> on 2006/09/19 07:01:08 UTC

[users@httpd] Re: Preventing mod_deflate dechunking of dynamic content

Hello,

on 09/18/2006 10:36 AM Joshua Slive said the following:
>> So I need to find another way of signaling mod_deflate/mod_gzip to not
>> dechunk the response.
>>
>> I think I could emit a custom response header like "x-dechunk: no" or
>> something else as a flag to prevent dechunking.
>>
>> However, I do not know how to configure mod_deflate/mod_gzip to act upon
>> that flag. Anybody has any ideas?
> 
> I don't think you are looking at this from the right perspective.  The
> decision to use chunked encoding or not happens at a different level
> than the mod_deflate decision.  My guess is that you are not seeing
> chunking because mod_deflate needs to accumulate a bunch of content
> before compressing it in order to get the optimal compression.  This
> is controlled by the DeflateBufferSize directive.  If it happens to
> get the entire response, then the optimal decision for the chunking
> layer is to send the known content-length, rather than chunking the
> response.
> 
> You could try reducing DeflateBufferSize, in which case it is more
> likely that incomplete responses (with unknown total content length)
> will be sent to the chunking layer, hence resulting in chunked
> responses to the client.

Joshua, thank you for the insight.

What I really need is to be able to force chunked response only on
specific requests to PHP scripts.

If it is not possible or desirable to serve compressed chunked
responses, then what I need to be able to force uncompressed chunked
responses on specific requests.

I know how to disable mod_gzip/mod_deflate for specific URI. However,
that is not what I want because I need to serve chunked responses or not
for requests to the same URI, depending on conditions evaluated
dynamically by the PHP scripts.

So, my doubt is: how can I configure Apache to return a response that
may trigger chunking/compression or not that mod_gzip/mod_deflate performs ?

I though of returning a custom header like "x-dechunk: no" from the PHP
script response. But how can I configure Apache with
mod_gzip/mod_deflate to not compress responses when that header is
returned by a PHP script?

Any other solution?

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: Preventing mod_deflate dechunking of dynamic content

Posted by Manuel Lemos <ml...@acm.org>.
Hello,

on 09/19/2006 02:38 PM Joshua Slive said the following:
> On 9/19/06, Manuel Lemos <ml...@acm.org> wrote:
>> So, my doubt is: how can I configure Apache to return a response that
>> may trigger chunking/compression or not that mod_gzip/mod_deflate
>> performs ?
>>
>> I though of returning a custom header like "x-dechunk: no" from the PHP
>> script response. But how can I configure Apache with
>> mod_gzip/mod_deflate to not compress responses when that header is
>> returned by a PHP script?
> 
> It's easy enough to turn on or off deflate per-request using the
> no-gzip environment variable.  But unfortunately, I don't think there
> is any way to set an environment variable based on a response header.
> This is because env variables need to be set early in order to be
> useful for content handlers.  So they are set too early to look at
> response headers.
> 
> One option would be to have your php script do an internal redirect to
> a non-deflated page.  Another option would be to deflate everything,
> but pad small response segments up to DeflateBufferSize.  (The padding
> should be mostly compressed away anyway.)

Looking closer at the problem, I realized that mod_deflate does not
dechunk gzip compressed responses, like mod_gzip does.

So, for the purpose of flushing HTML blocks with Javascript sections,
that is fine, although I wonder if the overhead of compress small blocks
 still pays the bandwidth/throughput benefits. Maybe it does.

Now I wonder if there is a way to force dechunking Apache 2 responses.

OTOH, mod_gzip allows turning off compression (and its dechunking)
dynamically with configuration line like thos:

mod_gzip_item_exclude         rspheader  "X-do-not-compress-this: yes"

So, when my PHP scripts issue the header X-do-not-compress-this,
mod_gzip does not compress the response nor dechunks it.

Dechunking by mod_gzip is turned on by the mod_gzip_dechunk
configuration option . There seems to not exist an option to do that
dynamically. I wonder if there is a way to turn off dechunking with
setenvif .

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: Preventing mod_deflate dechunking of dynamic content

Posted by Joshua Slive <jo...@slive.ca>.
On 9/19/06, Manuel Lemos <ml...@acm.org> wrote:
> What I really need is to be able to force chunked response only on
> specific requests to PHP scripts.
>
> If it is not possible or desirable to serve compressed chunked
> responses, then what I need to be able to force uncompressed chunked
> responses on specific requests.
>
> I know how to disable mod_gzip/mod_deflate for specific URI. However,
> that is not what I want because I need to serve chunked responses or not
> for requests to the same URI, depending on conditions evaluated
> dynamically by the PHP scripts.
>
> So, my doubt is: how can I configure Apache to return a response that
> may trigger chunking/compression or not that mod_gzip/mod_deflate performs ?
>
> I though of returning a custom header like "x-dechunk: no" from the PHP
> script response. But how can I configure Apache with
> mod_gzip/mod_deflate to not compress responses when that header is
> returned by a PHP script?

It's easy enough to turn on or off deflate per-request using the
no-gzip environment variable.  But unfortunately, I don't think there
is any way to set an environment variable based on a response header.
This is because env variables need to be set early in order to be
useful for content handlers.  So they are set too early to look at
response headers.

One option would be to have your php script do an internal redirect to
a non-deflated page.  Another option would be to deflate everything,
but pad small response segments up to DeflateBufferSize.  (The padding
should be mostly compressed away anyway.)

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org