Tag: 缓存控制

expires_in max-age缓存控制不起作用

我无法让max-age缓存控件正常工作,我使用expires_in导致“Cache-Control:max-age = 86400,public,must-revalidate”标头。 但是,浏览器仍然将请求发送到服务器,至少它被定义为“304 not modified”,这意味着ETag / If-None-Match标头正常工作。 我已经在我的localhost和heroku上用webrick测试了它,使用chrome 45和Safari。 不,我的开发工具没有打开,并且未选中“禁用缓存”。 我也试图删除expires_in方法调用的“,must_revalidate:true”。 我错过了什么? 以下是Chrome中网络的输出: 常规:远程地址:127.0.0.1:3000请求URL: http ://localtest.me:3000 / api / books请求方法:GET状态代码:304未修改 响应标头: Access-Control-Allow-Origin:* Access-Control-Request-Method:* Cache-Control:max-age = 86400,public,must-revalidate Connection:Keep-Alive Date:Tue,08 Sep 2015 13: 28:01 GMT Etag:W /“1f1b2d0b822830bc74e7c47a116205be”服务器:WEBrick / 1.3.1(Ruby / 2.2.1 / 2015-02-26)X-Content-Type-Options:nosniff X-Frame-Options:SAMEORIGIN X-Request -Id:c70d4715-dcff-4558-85af-9d21556d406a X-Runtime:0.553353 X-Xss-Protection:1; 模式=块 请求标题:接受:text / html,application / xhtml + xml,application […]

如何强制Cache-Control在rails 3.2.20中禁止存储

关于此,有几个SO问题: Rails(set_no_cache方法)无法在Safari和Opera中禁用浏览器缓存 如何防止Rails中的浏览器页面缓存 但无论我做什么,我覆盖什么,我仍然得到标题(FireFox,Chrome, curl -V ,……任何浏览器) Cache-Control: must-revalidate, private, max-age=0 我试过了 class ApplicationsController < ActionController::Base before_filter :no_store_cache after_filter :no_store_cache def no_store_cache response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" response.headers["Pragma"] = "no-cache" response.headers["Expires"] = '-1' end end 我试图直接在ActionController::Base上调用这个回调( https://github.com/equivalent/no_cache_control.git ) 我试图挖掘机rack-cache中间件覆盖试图强制执行标头的东西 我创建了自己的中间件,它覆盖了header[‘Cache-Control’] 。 什么都行不通