RE: [squid-users] Caching pages for users without a cookie (guest)

From: Elli Albek <elli_at_sustainlane.com>
Date: Thu, 15 Jan 2009 15:32:17 -0800

Amos what about this:

I add a squid URL rewrite rule, that whenever the cookie exists, append a
meaningless query parameter to the URL.

The origin server will ignore this parameter, and squid will not try to
cache the URL since it has a query parameter.

Example: A logged in user goes to the page /san-francisco, it will be
rewritten to /san-francisco?foo=bar

But for guest it will not be rewritten, so squid will cache the results
based on the reply headers for guest.

Does that sound like a solution?

E

-----Original Message-----
From: Amos Jeffries [mailto:squid3_at_treenet.co.nz]
Sent: Wednesday, January 14, 2009 12:03 PM
To: Elli Albek
Cc: Amos Jeffries; squid-users_at_squid-cache.org
Subject: Re: [squid-users] Caching pages for users without a cookie (guest)

> The thing is that squid should cache for some users and not for other
> users.
>
> Lets say we have two users, me (logged in) and guest (not logged in).
>
> Both ask for the same page with this sequence:
> 1. guest
> 2. me
> 3. guest
>
> Then we want:
> 1. guest: get page from origin and cache the response (cache miss).
> 2. me: get page from origin again, do not cache the response (cache
> bypassed).
> 3. guest: get page from cache, do not go to origin server (cache hit).
>
> Response 1 has Expires and max-age headers, but squid should NOT honor
> them in request 2 and should honor them in request 3. This decision is
> based on the cookie. So the cookie acl will override the expected HTTP
> based behaviour.
>
> I think a regular expression on the cookie can determine if squid should
> go to the origin server (regardless of what is in the cache) or act as
> normal (cache based on HTTP headers). This is done per request. The
> response headers can be used only in request 3, but they should be ignored
> in request 2.

You mentioned Expires and Cache-Control, earlier. I just had a thought
that Vary: and ETag: headers may need to be set for these pages.

Squid will cache (1) then if (2) looks identical but has auth headers it
will purge the cached copy (page has apparently become private/authed) and
have to fetch a new one for (3).
With Vary: something (I'm not sure if Cookie: or *-Auth* values are best)
Squid may be expected to cache the copies differently.

To test whether this is right try this sequence:
  (1), (guest), (2), (3), (guest)

If it is a vary issues I would expect the marked (guest) to be HIT but (3)
to be MISS despite the earlier (1).

Amos
Received on Thu Jan 15 2009 - 23:32:22 MST

This archive was generated by hypermail 2.2.0 : Fri Jan 16 2009 - 12:00:03 MST