Strange different behavior

John Norman john at
Fri Jan 15 13:49:40 CET 2010

Sorry to be so obtuse:

So with the default setup, there will be a cached copy of a page for
every single user agent?

If so, does anyone have a good number of user agents that should be
supported for calculating the size of the cache? E.g., if I've guessed
64M for my pages, and I imagine that there are 10 user agents (I know
it's more) then I'd want to multiply that 64M x 10.

On Fri, Jan 15, 2010 at 4:19 AM, Poul-Henning Kamp <phk at> wrote:
> In message <20100114215025.GB9573 at>, Kristian Lyngstol writes
> :
>>Vary on User-Agent is generally bad, and you should Just Fix That [tm].
> Apart from the compatibility issue, a secondary reason it is a bad
> idea, is that User-Agent is practically unique for every single PC
> in the world, so you will cache up to hundreds of copies of the pages
> for no good reason.
> If your site is running live on Varnish, try running:
>        varnishtop -i rxheader -I User-Agent
> and see how many different strings your clients send you...
> In all likelyhood, your backend looks at only one or two of the bits
> in User-Agent (MSIE or Mozilla ?) but Varnish has to look at the
> entire string, since it has no way of knowing what your backend
> looks at.
> One workaround, is to do what we call "User-Agent-Washing", where
> Varnish rewrites the Useragent to the handfull of different variants
> your backend really cares about, along the lines of:
> sub vcl_recv {
>        if (req.http.user-agent ~ "MSIE") {
>                set req.http.user-agent = "MSIE";
>        } else {
>                set req.http.user-agent = "Mozilla";
>        }
> }
> So that you only cache the relevant number of copies.
> But as Kristian says:  The best thing, is to not Vary on User-Agent
> in the first place, that's how the InterNet is supposed to work.
> 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.
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at

More information about the varnish-misc mailing list