quastion about keys

14 views
Skip to first unread message

tonio

unread,
Feb 7, 2011, 5:12:05 PM2/7/11
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

Ryan Tomayko

unread,
Feb 20, 2011, 4:18:25 AM2/20/11
to rack-...@googlegroups.com, tonio

That value is typically set when you use the Rack::Cache middleware in
your config.ru:

use Rack::Cache do |options|
options.set :cache_key do |request|
...
end
end

The full list of options is defined here:

https://github.com/rtomayko/rack-cache/blob/master/lib/rack/cache/options.rb#L27-96

Reply all
Reply to author
Forward
0 new messages