【发布时间】:2016-04-01 01:00:54
【问题描述】:
我在配置 Rails 4 以缓存图像时遇到问题。我正在使用 favicon 进行尝试,就实际性能提升而言,这可能是一个微不足道的案例,但无论如何我都想了解这方面。
我只是将网站图标放在我的public 文件夹中并以这种方式提供服务。我现在尝试通过一个简单的控制器来提供它,以便我可以在 ActionController 中使用 expires_in 方法(描述为 here)。
class DocumentsController < ApplicationController
# ...
def favicon
expires_in 30.minutes, :public => true
send_file Rails.root.join('public/', 'images/', 'favicon.ico'), type: 'image/x-icon', disposition: 'inline'
end
end
但没有骰子。当我请求图像时,这是我在网络检查器中看到的 -
如您所见,它没有被缓存。有什么建议吗?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 caching http-caching