In message <[EMAIL PROTECTED]>, Audun Ytterdal writes:
>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.

How about this:

    sub vcl_recv {
        unset req.http.hash_input;      // Don't confuse me
        if (req.url == "/" &&
            req.http.User-Agent ~ "^Mozilla/5.0 \(iP(hone|od);" &&
            !req.http.User-Agent ~ "somecookie" ) {
                set req.backend = someother;
                set req.http.hash_input = "iphone";
        }
    }

    sub vcl_hash {
        set req.hash += req.http.hash_input;
    }

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED]         | 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
[email protected]
http://projects.linpro.no/mailman/listinfo/varnish-misc

Reply via email to