我被告知要防止用户信息泄露,只有"无缓存"的响应是不够的."无商店"也是必要的.
Cache-Control: no-cache, no-store
在阅读本规范http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html后,我仍然不太清楚为什么.
我目前的理解是它只适用于中间缓存服务器.即使"无缓存"作为响应,中间缓存服务器仍然可以将内容保存到非易失性存储.中间缓存服务器将决定是否使用保存的内容进行后续请求.但是,如果响应中存在"no-store",则不应该在中间缓存服务器上存储内容.所以,它更安全.
还有其他原因我们需要"无缓存"和"无商店"吗?
我们在使用Chrome缓存Glassfish服务器上的资源时出现问题.即使存在Last-Modified标头,Chrome也不会发送过期和无缓存标头,并且资源(大约4 MB SWF文件)正在被缓存.
有时Chrome会获得304代码,有时它只会获得200代码(来自缓存).我了解304 - Chrome可能会使用缓存版本来确定最近的Last-Modified日期.但有时它会执行200(来自缓存),它不返回任何标题信息,并且看起来Chrome只是假设文件未被修改而不是检查.
谷歌自己的网站声明如下:
HTTP/S支持浏览器对静态资源的本地缓存.一些最新的浏览器(例如IE 7,Chrome)使用启发式方法来决定缓存没有显式缓存头的所有资源的时间.
但这并没有提供明确的答案.这个启发式发布在任何地方吗?我意识到可能没有一个固定的答案(如30天),但一些通用指南会很有用.此外,如果设置了Last-Modified,我不明白为什么Chrome没有先烦回来检查.
如何在Edge浏览器上禁用或删除Windows 10中的浏览器缓存?
首选项和开发人员工具没有选项(F12)
我正在编写一个客户端,它正在对xml数据进行重复的http请求,这些请求随时间而变化.看起来Android堆栈正在缓存我的页面请求并重复返回同一页面.我如何确保每次都获得一个新页面?
- 代码---
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response;
    response = client.execute(request);
InputStream in;
in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
谢谢,格里
这是使用301/303/307重定向到动态短网址的后续问题,我尝试确定在目标网址频繁更改时实施短网址重定向的最佳方法.
虽然看起来301和307重定向都以相同的方式执行,但我关注的问题是301重定向缓存(如此处所述) - 是避免使用307重定向的最佳方法(我假设307重定向永远不会缓存?),或显式发送无缓存标头("缓存控制:无缓存,必须重新验证")?
redirect caching no-cache http-status-code-301 http-status-code-307
出于某种原因,Laravel似乎在最后一刻操纵响应头"Cache-Control".我想使浏览器缓存成为可能.
class TestController extends Controller
{
    public function getTest()
    {
        $response = new \Illuminate\Http\Response('test', 200, array(
            'Cache-Control' => 'max-age='.(config('imagecache.lifetime')*60).', public',
            'Content-Length' => strlen('test'),
        ));
        $response->setLastModified(new \DateTime('now'));
        $response->setExpires(\Carbon\Carbon::now()->addMinutes(config('imagecache.lifetime')));
        return $response;
     }
}
即使我使用"中间件之后"并且死掉了转发响应,我仍然会得到这个,这似乎对我来说是正确的.
Response {#625 ?
  +original: "test"
  +exception: null
  +headers: ResponseHeaderBag {#626 ?
    #computedCacheControl: array:2 [?
      "max-age" => "2592000"
      "public" => true
    ]
    #cookies: []
    #headerNames: array:5 [?]
    #headers: array:5 [?
      "cache-control" => array:1 [?
        0 => "max-age=2592000, public"
      ]
      "content-length" => array:1 [?
        0 => 4
      ]
      "date" => …设置缓存控制的正确方法是什么?
有时我看到使用header []
self.response.headers["Pragma"]="no-cache"
self.response.headers["Cache-Control"]="no-cache, no-store, must-revalidate, pre-check=0, post-check=0"
self.response.headers["Expires"]="Thu, 01 Dec 1994 16:00:00"
其他时候,我看到headers.add_header()
self.response.headers.add_header("Pragma","no-cache")
self.response.headers.add_header("Cache-Control","no-cache, no-store, must-revalidate, pre-check=0, post-check=0")
self.response.headers.add_header("Expires","Thu, 01 Dec 1994 16:00:00")
甚至是header []和headers.add_header()的混合
self.response.headers["Pragma"]="no-cache"
self.response.headers.add_header("Cache-Control","no-cache, no-store, must-revalidate, pre-check=0, post-check=0")
self.response.headers.add_header("Expires","Thu, 01 Dec 1994 16:00:00")
我正处于一个项目的中间,昨天我开始使用CloudFlare.
问题是,当我进行更改时,我无法在浏览器中看到它,所以我认为这里的问题是CloudFlare的缓存设置.
我已经阅读了关于CloudFlare缓存的链接,所以我在我的html中添加了一个元标记:
<meta http-equiv="Cache-control" content="private">
但问题仍然存在.
我应该放置其他元标记,还是阻止服务器端的缓存?(我正在使用PHP)
我使用 nginx 作为反向代理来连接 api。问题是当我在添加或删除某些内容后发送查询时。Nginx 将旧的 json 值发送给我。我试图禁用缓存,但它不起作用。
我的 nginx 配置:
location  / {
  sendfile off;
  add_header Last-Modified $date_gmt;
  add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  if_modified_since off;
  expires off;
  etag off;
  proxy_no_cache 1;
  proxy_cache_bypass 1;
  proxy_pass http://127.0.0.1:5000;
  proxy_set_header Host $http_host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header HTTPS   $https;
}
我尝试在没有 nginx 的情况下进行查询,并且在控制台中一切正常
谢谢你!
我无法强制页面始终在Safari中过期.Chrome,IE和Firefox都是好公民,但是Safari正在巡航,忽略了以下ASP.NET代码:
// Expire immediately
Response.Expires = 0;
Response.Cache.SetNoStore();
Response.AppendHeader("Pragma", "no-cache");
有什么建议?