Caching issue

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Mar 10 23:54:19 CET 2008


My guess is  that Vary processing is getting you:


Firefox sends:
	   12 RxHeader     c Accept-Encoding: gzip,deflate
which goes to the backend:
	   15 TxHeader     b Accept-Encoding: gzip,deflate
which the backend uses:
	   15 RxHeader     b Vary: Accept-Encoding
	   15 RxHeader     b Content-Encoding: gzip

Then IE sends:
	   12 RxHeader     c Accept-Encoding: gzip, deflate

Which you will notice, has a space between "gzip," and "deflate"
thus not matching the Vary string already on record in the
cached object.

Varnish requires exact matching, the logic to find out if they
match semantically is not trivial to implement.

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.

And finally, giving up on gzip'ing in toto, which is probably a bad choice:

	unset req.http.accept-encoding;

Poul-Henning

-- 
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