Caching issue
Dag-Erling Smørgrav
des at linpro.no
Tue Mar 11 10:22:58 CET 2008
"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
> You could try the following in vcl_recv:
>
> if (req.http.accept-encoding) {
> set req.http.accept-encoding = regsub(
> req.http.accept-encoding,
> "gzip, *", "gzip,");
> }
>
> to get rid of the space(s), but it is not guaranteed to get all cases.
>
> Alternatively, the more brutal:
>
> if (req.http.accept-encoding ~ "gzip") {
> set req.http.accept-encoding = "gzip";
> } else {
> unset req.http.accept-encoding;
> }
>
> Will get the desired effect in all cases, provided your backend does
> not attempt deflate as fallback.
A slightly more complex solution, to cover all bases without losing
functionality:
set req.http.accept-encoding = regsub(req.http.accept-encoding,
"^ *gzip, *deflate *$", "gzip,deflate");
set req.http.accept-encoding = regsub(req.http.accept-encoding,
"^ *deflate, *gzip *$", "gzip,deflate");
This should take care of >99% of cases; I don't know of any browser that
supports only one of the two, or supports anything *but* those two.
However, Apache only supports gzip, so Poul-Henning's solution is
sufficient in this case.
DES
--
Dag-Erling Smørgrav
Senior Software Developer
Linpro AS - www.linpro.no
More information about the varnish-dev
mailing list