Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome 当PUT请求包含If匹配头时,Chrome不会使缓存无效_Google Chrome_Http_Browser Cache_Cache Control - Fatal编程技术网

Google chrome 当PUT请求包含If匹配头时,Chrome不会使缓存无效

Google chrome 当PUT请求包含If匹配头时,Chrome不会使缓存无效,google-chrome,http,browser-cache,cache-control,Google Chrome,Http,Browser Cache,Cache Control,我正在创建一个HTTP Web API,其中一些资源可以缓存。可缓存资源将有两个操作:GET和PUT。GET将返回Cache-Control:public,max-age=3600&Etag:2kuSN7rMzfGcB2DKt67EqDWQELA的响应头。PUT将需要If-Match标头,该标头将包含来自同一资源的GET的Etag值。我的目标是让浏览器缓存在我放入某个资源时使该资源无效。在我将If-Match头添加到PUT请求之前,这一切都很正常。当PUT请求包含If Match标头时,后续GE

我正在创建一个HTTP Web API,其中一些资源可以缓存。可缓存资源将有两个操作:GET和PUT。GET将返回Cache-Control:public,max-age=3600&Etag:2kuSN7rMzfGcB2DKt67EqDWQELA的响应头。PUT将需要If-Match标头,该标头将包含来自同一资源的GET的Etag值。我的目标是让浏览器缓存在我放入某个资源时使该资源无效。在我将If-Match头添加到PUT请求之前,这一切都很正常。当PUT请求包含If Match标头时,后续GET请求将从缓存中提取过时数据。这就是我在使用Chrome时所经历的行为。Firefox不是这样的,我认为它应该这样工作。这是Chrome中的一个bug还是我误解了HTTP规范的某些部分

以下是一些显示行为的示例请求:

//correctly fetchs from origin server (returns 200)
GET http://localhost/api/my-number/1
  Response Headers
    cache-control: public,max-age=3600
    etag: "2kuSN7rMzfGcB2DKt67EqDWQELA"
  Response Body
    7

//correctly fetchs from disk cache (returns 200)
GET http://localhost/api/my-number/1
  Response Headers
    cache-control: public,max-age=3600
    etag: "2kuSN7rMzfGcB2DKt67EqDWQELA"
  Response Body
    7

//correctly updates origin server (returns 200)
PUT http://localhost/api/my-number/1
  Request Headers
    if-match: "2kuSN7rMzfGcB2DKt67EqDWQELA"
  Request Body
    8

//incorrectly still fetches from disk cache (returns 200)
GET http://localhost/api/my-number/1
  Response Headers
    cache-control: public,max-age=3600
    etag: "2kuSN7rMzfGcB2DKt67EqDWQELA"
  Response Body
    7

这确实是不正确的行为。说:

缓存必须使有效的请求URI无效。。。以及位置和内容位置中的URI 非错误状态代码为时,如果存在响应标头字段 在响应不安全的请求方法时接收


有鉴于此,您提交的文件对我来说似乎是合适的。

这确实是不正确的行为。说:

缓存必须使有效的请求URI无效。。。以及位置和内容位置中的URI 非错误状态代码为时,如果存在响应标头字段 在响应不安全的请求方法时接收

考虑到这一点,你提交的文件对我来说很合适