在 padrino-cache 中缓存带有查询字符串的页面

Caching pages with query strings in padrino-cache

我的应用程序中有 Padrino 缓存,例如

get :blog, cache: true do
# do a blog listing
end

但是当列表用 will-paginate 分页时,它无法分辨 /blog/blog?page=2 之间的区别,并且总是呈现 /blog 的缓存副本.有什么方法可以让它工作,以便它按 URL 而不是按路线缓存?

一些 spelunking in the Padrino issues 提供了这个答案,似乎有效:

get :blog, cache: Padrino.config.cache do
  cache_key { request.path_info + '?' + params.slice('page').to_param }
  #do blog listing
end

Padrino 文档的结构从那时起似乎发生了变化,因此该问题末尾的 PR 似乎不再出现在当前文档中。