0

I am currently working on a large website in django(very complex data structure), natively, the load support is extremely low(4 req/s), which is unacceptable, I was advised to use varnish to speed up my application. Now here is where the problem lies, I used memcaching throughout my site, quite heavily i might add(pretty much every single query gets memcached). I could not use the middle ware as there are portions of the website which is per-user dynamic. Now the real problem I ran into with varnish was that a lot of pages need to be cached per user, and with varnish if there are cookies going back and forth it does not cache pages, what I'm wondering is if there is a way to cache pages in varnish per user-agent, and if this is really efficient, and if not, what might be the next best caching solution which allows said flexibility to maximize application performance

flaiks
  • 269
  • 3
  • 13

1 Answers1

0

Varnish can be used even with cookies.

I am showing here how varnish can be used for a particular path, see if you can use this to your benefit:


sub vcl_recv {
    if (req.url ~ "^/user1") {
        unset req.http.cookie;
    }
}

sub vcl_fetch {
    if (req.url ~ "^/user1") {
        unset beresp.http.set-cookie;
    }
}

or something like this:

sub vcl_hash {
    if (req.url ~ "^/user1") {
        hash_data(req.http.cookie);
    }
}
deep
  • 841
  • 7
  • 6