Cookies, User-agents and Hashes

Audun Ytterdal ay at vg.no
Mon Jul 21 15:35:30 CEST 2008


Lets say you have this site that when browsing with for example an
iphone you are sendt to another backend with scaled down content for
your eyes only. You users like this light version of you site, but some
still wants to see the full version with all bells and whistles

What I've done so far:

in vcl_recv {

        if (req.url == "/" && req.http.User-Agent ~ "^Mozilla/5.0
\(iP(hone|od);" &&  !req.http.User-Agent ~ "somecookie" ) {
                set req.backend = someother;
                pass;
        }

It's set to pass because otherwise it will on a hit lookup the same hash
as the non-iphone users and visa-versa

I could add User-Agent to my hash, but that is a bit overkill and would
make my cache 10-30 times larger. A substring might help a bit here.

Or I could maybe just copy all the if's in vcl_recv and add a extra
number to the hash for each if. But then I would have to duplicate alot
of lines. especially when adding cookies and stuff.

Is this the correct way of doing things? It would be nice if you could
set hash allready in vcl_recv..

--
Audun



*****************************************************************
Denne fotnoten bekrefter at denne e-postmeldingen ble
skannet av MailSweeper og funnet fri for virus.
*****************************************************************
This footnote confirms that this email message has been 
swept by MailSweeper for the presence of computer viruses.
*****************************************************************




More information about the varnish-misc mailing list