进行分页/无限滚动时如何进行页面缓存?
我有大量数据集要显示,其中顺序不断变化(例如 SO、HN、Reddit)。由于 Rails 在页面和操作级别进行缓存,如果像本例中呈现的操作需要根据分页参数而有所不同,我该怎么办?
我能想到的几个策略:
- 仅在 redis/memcached 中进行对象缓存 - 但我的大部分时间都花在渲染上;如果我这样做,理想情况下我必须将渲染移至 javascript 并
- 使用 eTags - 但客户端仍然必须获取该页面一次。
- 缓存整个渲染的数据集,并将一些逻辑放入控制器中以获取所需的页面。使用清扫器将其过期。
我怎样才能最好地“开箱即用”?我想介绍最小的复杂性。
I have large dataset to display in which the order is constantly changing (like SO, HN, Reddit). Since Rails does caching at the page and action level, what can I do if the action rendered like in the case needs to be different depending on pagination params?
A couple strategies I could think of:
- Do just object caching in redis/memcached - but most of my time is being spent in rendering ; if I did this I'd ideally have to move the rendering into javascript as well
- use eTags - but then the client still has to get the page once.
- cache the entire rendered dataset, and put some logic into the controller to grab the page it needs. Use a sweeper to expire it.
How can I best do this "out of the box?" I want to introduce the minimum amount of complexity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论