0

我们的Rails 4.2应用程序在生产环境中运行,具有以下配置(与缓存相关)。到目前为止,我们还没有实现任何缓存技术(默认设置)。

config.action_controller.perform_caching = true

# Use a different cache store in production.
# config.cache_store = :mem_cache_store

我遇到了特定视图的问题,该视图没有相应地显示更新的数据。

有没有办法可以为不在整个应用程序中的特定视图禁用片段缓存?

4

1 回答 1

1

TLDR:虽然缓存可能会导致问题,但在尝试修复它之前验证您是否实际使用它是值得的!

禁用单个视图缓存的最简单方法也是最明显的(但可能很容易错过):

从您的视图中删除cache model do块。

默认情况下,Rails 不会为您做任何缓存,所以它会完全处理它。如果您没有调用cache视图中的块,则说明您没有使用缓存

例如:

缓存:

# app/views/something_important/show.html.haml
= cache something_important do
  = render_something_expensive

未缓存:

# app/views/something_important/show.html.haml
= render_something_expensive
于 2017-08-07T14:57:46.297 回答