我正在尝试使用此行缓存一个返回json文件的操作
caches_page :events, :cache_path => '/events.json', :expires_in => 1.hour
def events
respond_to do |format|
format.text do
render plain: result
response.content_type # => "text/plain"
end
format.json do
render json: result
end
end
但是当我向http://localhost:5000发送帖子时,结果不会被缓存。
答案 0 :(得分:0)
如果您使用的是Rails 4,caches_page
将无效,因为它已被删除。这是一个link to the Rails docs,以及DHH的一个blog post,解释了Rails中基于密钥的缓存。
如果你真的还想使用caches_page
,你将不得不使用可以找到的actionpack-page_caching gem here