Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The following page has been changed by slive: http://wiki.apache.org/httpd/ReInflating The comment on the change is: Add section headers to make this more readable ------------------------------------------------------------------------------ So you want to handle the text from a proxy or other app which has deflate'd the content? + + === Setup a log with debugging info === The first most valuable thing for diagnosing any issues is to create a compression log which will show you the Accept-Encoding (AE) permitted by the client (browser) along @@ -16, +18 @@ CustomLog logs/compression.log compression }}} + === Configuring a local test server === + The first thing is to provide a server to test against which deflates it's output. We can do this in the same instance of Apache, simply set up an alias to the htdocs for /deflated/ requests for the very same documents in /. @@ -35, +39 @@ }}} Note the response body has shrunk nearly to a quarter of it's original size. + + === Proxy requests to the local test server === For our first experiment (and we will keep it in our config as the LAST snippet, because this would override any other example below if it appears first), we will @@ -59, +65 @@ 127.0.0.1 "GET /proxy/deflated/LICENSE.txt HTTP/1.1" 200 10629 (10964) TE:"-" CE:"gzip" <-- 427 AE:"gzip,deflate" TE:"-" CE:"-" }}} + === Remove the request for compression === + Now the quick method of disabling compression is to never request a compressed document from the back-end machine, which we can accomplish by unset'ting the Accept-Encoding header from the client. @@ -76, +84 @@ 127.0.0.1 "GET /deflated/LICENSE.txt HTTP/1.1" 200 39858 (40169) TE:"-" CE:"-" <-- 479 AE:"-" TE:"-" CE:"-" 127.0.0.1 "GET /proxy/nodeflate/LICENSE.txt HTTP/1.1" 200 39858 (40169) TE:"-" CE:"-" <-- 428 AE:"-" TE:"-" CE:"-" }}} + + === Keep compression but inflate at the proxy === But if we want to continue to accept deflated content from the back end server for bandwidth conservation, it's possible to use mod_deflate to perform response @@ -101, +111 @@ 127.0.0.1 "GET /proxy/reinflate/LICENSE.txt HTTP/1.1" 200 39858 (40219) TE:"chunked" CE:"-" <-- 428 AE:"gzip,deflate" TE:"-" CE:"-" }}} + === Transform the inflated content === + Let's take this one step further, and add on a transformation. There's an experimental filter mod_case_filter which upper-cases the response, and it's perfect for illustrating the transformation. We can't upper-case the deflated binary stream, so we'll have to @@ -136, +148 @@ 127.0.0.1 "GET /proxy/ucase/LICENSE.txt HTTP/1.1" 200 39858 (40219) TE:"chunked" CE:"-" <-- 427 AE:"gzip,deflate" TE:"-" CE:"-" }}} + === Redeflate the transformed content === + Building on those two examples, we'll take this one step further, and ensure the final response can in fact be deflated to the client, so we'll name our redeflate filter gzdeflate and apply all three filters, in specific order, to inflate, @@ -159, +173 @@ With only 26 alpha characters rather than 52 (upper and lower case) it compresses down more efficiently than the back end had provided it to us. + + === Forward proxies === We can actually do this for forward proxies as well. Here is an example proxy server which inflating every C-E:gzip compressed response and serves only plain text to the
