在 Rails 4 中使用 send_data 方法渲染图像时,我试图将 Cache-Control header 设置为公共(public),但无论我做什么,Rails 都会将其更改为私有(private)..
Controller 代码:
response.headers['Cache-Control'] = 'public, max-age=31556926'
send_data data, disposition: 'inline'
在浏览器中查看时:
Cache-Control:max-age=31556926, private
我怎样才能去掉这个私有(private)关键字?
最佳答案
我通过使用 expires_in 方法而不是手动编辑 header 解决了这个问题:
expires_in 1.year, public: true
关于ruby-on-rails - Cache-Control header 通过 send_data 方法恢复为私有(private),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30658129/