Rails缓存:一项操作将使多个页面过期 [英] Rails caching: Expiring multiple pages for one action
问题描述
我已经在我的应用程序中设置了动作缓存(使用清除程序,但是我想这是不相关的),到目前为止,除了一件事之外,它都非常有用:
我使用Kaminari进行分页,因此,当我对操作执行expire_action
时,它只会使第一页过期.我知道使用查询字符串指定页面时缓存将不起作用,我已经设置了一条路由,以便将页面附加到url的末尾(例如/people/123/page/2). /p>
如有必要,我将在此帖子中添加更多信息,但我想这里显然缺少一些内容,因此:任何人都知道如何使其余页面失效吗?
我仍然对我的原始问题的答案感兴趣,并且如果解决方案出现,它将改变我接受的答案.就是说,我最终只是通过检查是否完全指定了页面来缓存原始页面:
caches_action:index,:if => Proc.new {params [:page] .nil? }
I've set up action caching (with sweepers, but I guess that's irrelevant here) in my app, and so far it works great except for one thing:
I use Kaminari for pagination, and thus when I execute expire_action
on my action it only expires the first page. As I know caching won't work when using the query string for specifying the page, I've set up a route so the pages are appended to the end of the url (for example /people/123/page/2).
I'll add more info to this post if necessary, but I'm guessing there is something obvious I'm missing here, so: Anyone know how to expire the rest of my pages?
I'm still interested in an answer to my original question and will change my accepted answer should a solution come up. That said, I ended up only caching the original page by checking if a page was specified at all:
caches_action :index, :if => Proc.new { params[:page].nil? }
这篇关于Rails缓存:一项操作将使多个页面过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!