簡體   English   中英

Cache-Control標頭通過send_data方法恢復為private

[英]Cache-Control header reverts to private with send_data method

我正在嘗試使用Rails 4中的send_data方法渲染圖像時將Cache-Control標頭設置為public,但無論我做什么,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設置Cache-Control和Expires標頭來解決問題。 奇怪的

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM