ruby on rails - Cache-Control头通过send_data方法恢复为私有



我试图在Rails 4中使用send_data方法渲染图像时将Cache-Control头设置为公共,但无论我做什么,Rails都将其更改为私有..

控制器代码:

response.headers['Cache-Control'] = 'public, max-age=31556926'
send_data data, disposition: 'inline'

在浏览器中查看时:

Cache-Control:max-age=31556926, private

我怎样才能摆脱这个私有关键字?

我通过使用expires_in方法而不是手动编辑标题来解决这个问题:

expires_in 1.year, public: true

我也遇到了同样的问题。单独使用expires_in并不能解决这个问题。我最终设置缓存控制和过期头手动和通过expires_in来解决这个问题。奇怪的

response.headers["Expires"] = 1.year.from_now.httpdate
response.headers["Cache-Control"] = 'public'
expires_in 1.year, public: true
send_file file

相关内容

最新更新