I'm refactoring my Varnish VCL and can't figure out this one thing.
Varnish 3.0 natively supports gzipped content, and it essentially seems to do the right thing. See also: https://stackoverflow.com/a/12962493/35434
However, Varnish still performs a gunzip step, according to varnishlog, even though the client requests gzipped content and the backend responds with gzipped content. According to the Varnish docs, Varnish defaults to do_gzip=true, and also stores cache-objects compressed. So, why the gunzip?
Here are the relevant log entries:
11 RxURL c /javascripts/general.js
11 RxHeader c Accept-Encoding: deflate, gzip
11 VCL_call c fetch
13 TxHeader b Accept-Encoding: gzip
13 RxHeader b Content-Encoding: gzip
13 RxHeader b Content-Type: application/javascript
11 Gzip c u F - 1554 4476 80 80 12365
11 VCL_call c deliver
11 TxHeader c Content-Encoding: gzip
As you can see, the entire pipeline supports gzip, yet Varnish performs a gunzip during vcl_fetch. I have the assume it stores the objects compressed, and as you can see it delivers it compressed as well.
After this request, varnishstat shows the gunzip operation occurred:
$ varnishstat -1 | grep zip
n_gzip 0 0.00 Gzip operations
n_gunzip 1 0.00 Gunzip operations
Note: My VCL has no gzip configuration at all, nor do I do anything with the object's body. I'm relying on the sensible defaults, hence I'm not showing the VCL.
A gunzip operation is relatively light, but I'd still like to understand why, and possibly prevent a few hundred-thousand operations.