Custom cache_key with cookies

22 views
Skip to first unread message

tonio

unread,
Feb 18, 2010, 2:24:14 PM2/18/10
to rack-cache
Hello everyone,

I loved rack-cache from the very first time that I used it, but now I
have a more complex requirement...

My app has a cookie with two important values: lang and country_code.
This values are similar to many people, but I need to cache
separately, because if I don't do it all the visitors see the site in
the same language and localization with the cache enable...

I was looking for the cache_key option and I was thinking to add
something like this:

set :cache_key do |request|
request.fullpath.replace(/\//, '-') + "-
lang:#{request.cookies['lang']}" +
"cc:#{request.cookies['country_code']}"
end

But I don't have a clue where I have to put that =(

Can anybody please help me telling me where...

Cheers,
José Antonio

Reply all
Reply to author
Forward
0 new messages