Individual Cache for different Browsers?

Josh josh at schulzone.org
Thu Dec 2 17:46:11 CET 2010


My guess is that it's the cookies you're sending through.  I had the
same problem and it turned out to be analytics cookies.

Those _ut* cookies look like the same thing.  You can strip those out
using something like this in vcl_recv

set req.http.Cookie = regsuball(req.http.Cookie,
"(^|;\s*)(__utma|__utms|etc...)=[^;]+;?", "");

and that should take care of it.

On Thu, Dec 2, 2010 at 5:32 AM, Klapproth, Martin
<Klapproth.M at sportresult.com> wrote:
> Hello,
>
>
>
> I have requested one page with different browsers (firefox, chrome). If I
> make a second request with the same browser I get the object from the
> varnish cache. But if the first browser makes the first request and the
> second browser makes the second one I get a miss.
>
>
>
> In my configuration the hash will be determined only by the url and host
> header (nothing else). Client side Cache-Control or Pragma headers were
> totally ignored. Here a snippet out of my vcl config:
>
>
>
> sub vcl_recv {
>
>         unset req.http.Pragma;
>
>         unset req.http.Cache-Control;
>
>         …
>
> }
>
>
>
> sub vcl_hash {
>
>     set req.hash += req.url;
>
>     if (req.url == "/") {
>
>         set req.hash += req.http.host;
>
>     }
>
>     return (hash);
>
> }
>
>
>
> sub vcl_deliver {
>
>            if (obj.hits > 0) {
>
>               set resp.http.X-Cache = "HIT";
>
>            } else {
>
>                 set resp.http.X-Cache = "MISS";
>
>            }
>
>            unset resp.http.X-Varnish;
>
> }
>
>
>
> Here the 2 browser requests:
>
>
>
> Request 1 by Firefox:
>
>
>
> Host: XXXXX
>
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12)
> Gecko/20101026 Firefox/3.6.12
>
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
>
> Accept-Language: en-us,en;q=0.5
>
> Accept-Encoding: gzip,deflate
>
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
>
> Keep-Alive: 115
>
> Connection: keep-alive
>
> Referer: XXXXX
>
> Cookie: __utma=31143592.1898076621.1291293810.1291291810.1291291810.1;
> __utmb=31173592; __utmc=31543592;
> __utmz=31143592.1291291810.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none);
> __utma=61459198.633465754.1291291861.1291241861.1291291861.1;
> __utmb=6145912.2.10.1291291861; __utmc=61459198;
> __utmz=61459198.1291881861.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none
>
>
>
> Response 1 (Request made by Firefox)
>
>
>
> Server: nginx
>
> Date: Thu, 02 Dec 2010 12:11:26 GMT
>
> Content-Type: text/html; Charset=utf-8
>
> Connection: keep-alive
>
> Keep-Alive: timeout=20
>
> Cache-Control: public, max-age=600
>
> Expires: Thu, 02 Dec 2010 12:21:26 GMT
>
> Last-Modified: Thu, 02 Dec 2010 12:11:26 GMT
>
> CacheInfo: 600
>
> Content-Encoding: gzip
>
> X-Cache: MISS           // that’s ok, cause the object wasn’t cached before
>
> Content-Length: 7978
>
> Age: 0
>
>
>
> Request 2 by Chrome
>
>
>
> Accept:
> application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
>
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
> AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7
>
>
>
> Response 2 by Chrome
>
>
>
> Age: 0
>
> Cache-Control: public, maxage=600
>
> CacheInfo: 600
>
> Connection: keep-alive
>
> Content-Encoding: gzip
>
> Content-Length: 8004
>
> Content-Type: text/html; Charset=utf-8
>
> Date: Thu, 02 Dec 2010 12:11:56 GMT
>
> Expires: Thu, 02 Dec 2010 12:21:56 GMT
>
> Keep-Alive: timeout=20
>
> Last-Modified: Thu, 02 Dec 2010 12:11:56 GMT
>
> Server: nginx
>
> X-Cache: MISS     // That’s not ok, cause the request was done 30 sec after
> the first one ant the max-age is 600
>
>
>
> The nginx is only proxying the request to varnish and handles gzip. The
> object will be cached (can see it in varnishlog).
>
>
>
> Can you help me with my problem?
>
>
>
> Thanks
>
>
>
> Martin
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>



-- 
josh
@schulz
http://schulzone.org




More information about the varnish-misc mailing list