Mailing List Archive

Caching pages with cookies - feature request
Hello List,


Could it be possible to cache pages per cookie values?

Example.

http://www.host.dk/page1?var=value1 (cookie: selection=1,2,3,4)

A object with url http://www.host.dk/page1?var=value1 with that cookie
would be cached .
Then, when the next time another user with same cookie, he gets the
cached version.

Also if a unique user session is set in a cookie. Then the user will not
get another users cached page, but only his own.
For example, if its a user who likes to hit reload button many times.
Pages with usersession would usually be cached for a few minutes.


Then you can use the vcl to make exceptions to what urls that shoult not
be cached. ex. when reload a mailbox page.

/Klaus
Caching pages with cookies - feature request [ In reply to ]
In message <46DABC11.9090608 at klaus.dk>, Klaus writes:
>Hello List,
>
>
>Could it be possible to cache pages per cookie values?
>
>Example.
>
>http://www.host.dk/page1?var=value1 (cookie: selection=1,2,3,4)

Yes, just add the cookie header to the hash string in vcl_hash():

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


Poul-Henning

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
Caching pages with cookies - feature request [ In reply to ]
Klaus <red5 at klaus.dk> writes:
> Could it be possible to cache pages per cookie values?

Yes, simply add the cookie header to the hash string.

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
Caching pages with cookies - feature request [ In reply to ]
Ah great!

But what if I only want to cache on some of the cookies. Like a
sessionID and ignore the rest?

/Klaus

Poul-Henning Kamp wrote:
> In message <46DABC11.9090608 at klaus.dk>, Klaus writes:
>
>> Hello List,
>>
>>
>> Could it be possible to cache pages per cookie values?
>>
>> Example.
>>
>> http://www.host.dk/page1?var=value1 (cookie: selection=1,2,3,4)
>>
>
> Yes, just add the cookie header to the hash string in vcl_hash():
>
> sub vcl_hash {
> set req.hash += req.http.cookie;
> }
>
>
> Poul-Henning
>
>
Caching pages with cookies - feature request [ In reply to ]
In message <46E82BB9.1010808 at klaus.dk>, Klaus writes:
>Ah great!
>
>But what if I only want to cache on some of the cookies. Like a
>sessionID and ignore the rest?

That's still in the pipeline. The intended syntax is:

set req.hash += req.http.cookie[SessionID];

But it's not implemented yet.

You can hack your way out of it for now with the regsub() function.


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.