Caching issue

Poul-Henning Kamp phk at phk.freebsd.dk
Tue Mar 11 11:04:03 CET 2008


Is this FAQ fodder ?

In message <87k5k9d37x.fsf at des.linpro.no>, =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=
 writes:
>"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 =3D 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 =3D "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 =3D regsub(req.http.accept-encoding,
>    "^ *gzip, *deflate *$", "gzip,deflate");
>set req.http.accept-encoding =3D 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
>--=20
>Dag-Erling Sm=C3=B8rgrav
>Senior Software Developer
>Linpro AS - www.linpro.no
>

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



More information about the varnish-dev mailing list