httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Eckert <thomas.r.w.eck...@gmail.com>
Subject Re: Revisiting: xml2enc, mod_proxy_html and content compression
Date Fri, 03 Jan 2014 13:39:01 GMT
After applying

@@ -1569,10 +1579,13 @@ static void proxy_html_insert(request_rec *r)
     proxy_html_conf *cfg;
     cfg = ap_get_module_config(r->per_dir_config, &proxy_html_module);
     if (cfg->enabled) {
-        if (xml2enc_filter)
+        ap_add_output_filter("INFLATE", NULL, r, r->connection);
+        if (xml2enc_filter) {
             xml2enc_filter(r, NULL, ENCIO_INPUT_CHECKS);
+        }
         ap_add_output_filter("proxy-html", NULL, r, r->connection);
         ap_add_output_filter("proxy-css", NULL, r, r->connection);
+        ap_add_output_filter("DEFLATE", NULL, r, r->connection);
     }
 }

a simple

  ProxyHTMLEnable On

will do the trick for simple text/html but I did have to remove the
mod_deflate config (see further down). This does not solve the problem
regarding .gz files however. They still suffer from a double-compression.
Using the above patch/configuration we could either
  1) patch mod_deflate to bail out when it sees a .gz file
or
  2) patch mod_proxy_html (in the above mentioned section) to bail out if
it sees a .gz file.
I cannot think of a situation where we would actually want to "HTTP
compress" a .gz file. There might also be other formats then gzip invovled
- at least the RFC allows for them, though I've only seen gzip in the wild.
For there two reasons I would to with 1).


In order to get the above patch working I also had to remove

  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE application/x-javascript
application/javascript application/ecmascript
  AddOutputFilterByType DEFLATE application/rss+xml

from the (global) configuration because the compression would kick in
*before* mod_xml2enc was called for the second time in the output filter
chain. This makes mod_xml2enc see compressed content and fail. Here's how
the output filter chain looks like at different points in time:

called: inflate_out_filter()
output filters:
inflate
xml2enc
proxy-html
proxy-css
BYTYPE:DEFLATE
deflate
mod_session_out
byterange
content_length
http_header
http_outerror
core

called: proxy_html_filter()
output filters:
xml2enc
proxy-html
proxy-css
BYTYPE:DEFLATE
deflate
mod_session_out
byterange
content_length
http_header
http_outerror
core

called: proxy_css_filter()
output filters:
xml2enc
proxy-html
proxy-css
BYTYPE:DEFLATE
xml2enc
deflate
mod_session_out
byterange
content_length
http_header
http_outerror
core

How do I move the second pass to xml2enc before BYTYPE:DEFLATE ? I'm not
aware of a variant of ap_add_output_filter() which lets one adjust the
position of the to-insert filter.

Solving this problem would allow to remove the call to
ap_add_output_filter() in the above patch, which in turn allows for nice
and clean configurations (e.g. by using the example config of mod_deflate)
as well as allowing the reverseproxy to do "HTTP compression" even if the
backend did not choose to do so.


On Thu, Dec 19, 2013 at 4:01 AM, Nick Kew <nick@webthing.com> wrote:

>
> On 18 Dec 2013, at 14:47, Thomas Eckert wrote:
>
> > No, yes and I tried but couldn't get it to work. Following your advice I
> went along the lines of
>
> Yes, I'd be trying something like that.  You can insert inflate (and
> deflate)
> unconditionally, as they will check the headers themselves and remove
> themselves if appropriate.
>
> But I'd make at least the deflate component of that configurable:
> many sysops may prefer to sacrifice compression to avoid that
> unnecessary overhead.
>
> --
> Nick Kew

Mime
View raw message