Logged-in users

2008-11-26 Thread Miles
Hi,

I have a site where users can log in.  This sets a cookie with their 
encrypted login details, so they can be authenticated.  There are a 
small number of pages which are user-specific (change your details 
forms, etc), and these are set not to cache.

When a user is logged in, a message is shown at the top of the page You 
are now logged in.  However, nothing on the page depends on the 
individual user.

My question is, how can I organise the cache to have the most cache 
hits, given that there are effectively two versions of each page - one 
for logged in users, and one for anonymous users.

Thanks,

Miles

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Logged-in users

2008-11-26 Thread Miles
Hi,

I have a site where users can log in.  This sets a cookie with their 
encrypted login details, so they can be authenticated.  There are a 
small number of pages which are user-specific (change your details 
forms, etc), and these are set not to cache.

When a user is logged in, a message is shown at the top of the page You 
are now logged in.  However, nothing on the page depends on the 
individual user.

My question is, how can I organise the cache to have the most cache 
hits, given that there are effectively two versions of each page - one 
for logged in users, and one for anonymous users.  I want to 
specifically avoid each user having their own version of the page stored 
in the cache.

Thanks in advance for any wisdom anyone can share!

Miles

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Logged-in users

2008-11-26 Thread Miles
Miles wrote:
 Hi,
 
 I have a site where users can log in.  This sets a cookie with their 
 encrypted login details, so they can be authenticated.  There are a 
 small number of pages which are user-specific (change your details 
 forms, etc), and these are set not to cache.
 
 When a user is logged in, a message is shown at the top of the page You 
 are now logged in.  However, nothing on the page depends on the 
 individual user.
 
 My question is, how can I organise the cache to have the most cache 
 hits, given that there are effectively two versions of each page - one 
 for logged in users, and one for anonymous users.  I want to 
 specifically avoid each user having their own version of the page stored 
 in the cache.
 
 Thanks in advance for any wisdom anyone can share!
 
 Miles

Thanks to everyone who suggested using ESI - I may have to use this, but 
would quite like to avoid it, as it's useful to be able to run the app 
without varnish in front for development/testing.

I wondered whether it was possible to use vcl_hash for my purposes, as 
follows:

sub vcl_hash {

//hash the object with url+host
set req.hash += req.url;
set req.hash += req.http.host;

# see if the user has a cookie to indicate they are logged in
if req.http.cookie ~ '__ac=':
   set req.hash += 'authenticated';
else:
   set req.hash += 'anonymous'
hash;

}

Would this give me the two representations that I require for each page 
- or am I going down a route that will turn out bad?!  I couldn't find 
much information about vcl_hash, so I'm not sure if I'm barking up the 
wrong tree or not...

Regards,

Miles

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


varnish cache keys

2008-11-17 Thread Miles
Hi,

Can someone confirm the default behaviour of varnish in terms of it's 
cache keys?

By default - and without a vary header - is the cache keyed on hostname 
and url only?  If a vary header is added, then the cache also uses those 
headers to key the request.

Specifically, are cookies are ignored by the cache unless specified in 
the vary header or special behaviour in VCL?

I'm trying to understand why we get a low level of cache hits, and want 
to be certain of the facts.

Thanks,

Miles

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


caching using ETags to vary the content

2008-11-04 Thread Miles
Hi

I am using varnish 2.0-beta-2.

I am using varnish to cache a website where there is a small amount of 
personalised content in a particular directory.  When the user is 
outside of that directory, the only difference for logged-in and 
non-logged-in users is a few links (e.g. login/register or view 
profile/logout - the targets are the same irrespective of which user). 
I am trying to come up with a cache setup to deal with this.

How I had planned to deal with this was as follows:
  - set an ETag (e.g. logged-in or anon) depending on whether the 
user is logged in or not;
  - add a Vary: ETag header, so varnish stores several representations
  - in varnish, set an ETag header on the request when it is received, 
depending on if the user is authenticated or not (can be determined by 
the presence of a cookie).  the request should then match the correct 
page in the cache.

I know varnish doesn't do If-None-Match, but I don't think that is a 
problem in this scheme.

I haven't attempted this yet - can anyone see any holes in it as a 
method?  Or does anyone else have a way of dealing with this sort of 
personalisation-lite?!

Thanks in advance for your help!

Miles

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


varnish in front of load balancer

2008-11-04 Thread Miles
Hi,

Second question - we are running varnish in front of a load balander. 
The load balancer has stickiness - requests go to the same backend 
server each time, unless that server goes down.  The stickiness is 
provided by a cookie which is set on the first request, and then read to 
direct the request to the right backend.

What I want to do is ignore these cookies when trying to decide whether 
the request can be served from the cache or not - but if it can't be 
served from the cache, then pass the cookies on.

I've seen examples on completely ignoring cookies, but not that cover 
this case.

Thanks in advance,

Miles

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Conditional GET (was Re: caching using ETags to vary the content)

2008-11-04 Thread Miles
Ryan Tomayko wrote:
 On 11/4/08 12:51 PM, Miles wrote:
 I know varnish doesn't do If-None-Match, but I don't think that is a
 problem in this scheme.
 
 I'm curious to understand why Varnish doesn't do validation / conditional GET.
 Has If-Modified-Since/If-None-Match support been considered and rejected on
 merit or is it something that could theoretically be accepted into the
 project? Has it just not received any real interest?
 
 Personally, I'd love to see support for conditional GET as this can
 significantly reduce backend resource use when the backend generates cache
 validators upfront and 304's without generating the full response.
 
 Ryan

AFAIK varnish does do if-modified-since, just not if-none-match

Miles

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc