原始网站没有按我认为应该的方式缓存html,css或图像。谷歌chrome har的结果只是一个图像,同时在网站上请求不同的页面是在下面。这是一个更大的浏览网站的一部分,试图找出浏览器认为应该缓存但浏览器是从服务器重新请求的原因。我删除了与此图像没有特别关联的所有内容。
我没有任何缓存杀手或缓存禁用程序。我甚至去了相对干净的计算机,以确保没有安装任何可能会破坏缓存的开发工具。
第一个请求中的所有请求/响应标头似乎暗示第二个和第三个请求不应该发出重新请求,而是来自浏览器本地缓存。
我错过了什么?
{
"startedDateTime": "2017-02-10T21:21:44.273Z",
"time": 56.46199999999624,
"request": {
"method": "GET",
"url": "http://616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com/images/default-source/site-cdn/LoginLogo.png",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "image/webp,image/*,*/*;q=0.8"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, sdch"
},
{
"name": "Referer",
"value": "http://authentrip.com/"
},
{
"name": "Host",
"value": "616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com"
},
{
"name": "Accept-Language",
"value": "en-US,en;q=0.8"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
}
],
"queryString": [],
"cookies": [],
"headersSize": 428,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Fri, 10 Feb 2017 21:21:44 GMT"
},
{
"name": "Origin",
"value": "https://mycloud.rackspace.com"
},
{
"name": "Last-Modified",
"value": "Fri, 09 Dec 2016 05:10:48 GMT"
},
{
"name": "ETag",
"value": "ab904584a8e355da2fd0437065839e10"
},
{
"name": "Content-Type",
"value": "image/png"
},
{
"name": "X-Timestamp",
"value": "1481260247.52133"
},
{
"name": "Cache-Control",
"value": "public, max-age=349"
},
{
"name": "Content-Length",
"value": "6397"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Ranges",
"value": "bytes"
},
{
"name": "X-Trans-Id",
"value": "txbeec00752b6a4e1e9e3b5-00589e2ca4dfw1"
},
{
"name": "Expires",
"value": "Fri, 10 Feb 2017 21:27:33 GMT"
}
],
"cookies": [],
"content": {
"size": 6397,
"mimeType": "image/png",
"compression": 0
},
"redirectURL": "",
"headersSize": 433,
"bodySize": 6397,
"_transferSize": 6830
},
"cache": {},
"timings": {
"blocked": 0.396999999992431,
"dns": -1,
"connect": -1,
"send": 0.13800000000685503,
"wait": 23.861999999994016,
"receive": 32.06500000000294,
"ssl": -1
},
"serverIPAddress": "204.2.145.184",
"connection": "989",
"pageref": "page_1"
},
{
"startedDateTime": "2017-02-10T21:22:48.357Z",
"time": 0,
"request": {
"method": "GET",
"url": "http://616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com/images/default-source/site-cdn/LoginLogo.png",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "image/webp,image/*,*/*;q=0.8"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, sdch"
},
{
"name": "Referer",
"value": "http://authentrip.com/"
},
{
"name": "Host",
"value": "616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com"
},
{
"name": "Accept-Language",
"value": "en-US,en;q=0.8"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
}
],
"queryString": [],
"cookies": [],
"headersSize": 428,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Fri, 10 Feb 2017 21:21:44 GMT"
},
{
"name": "Origin",
"value": "https://mycloud.rackspace.com"
},
{
"name": "Last-Modified",
"value": "Fri, 09 Dec 2016 05:10:48 GMT"
},
{
"name": "ETag",
"value": "ab904584a8e355da2fd0437065839e10"
},
{
"name": "Content-Type",
"value": "image/png"
},
{
"name": "X-Timestamp",
"value": "1481260247.52133"
},
{
"name": "Cache-Control",
"value": "public, max-age=349"
},
{
"name": "Content-Length",
"value": "6397"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Ranges",
"value": "bytes"
},
{
"name": "X-Trans-Id",
"value": "txbeec00752b6a4e1e9e3b5-00589e2ca4dfw1"
},
{
"name": "Expires",
"value": "Fri, 10 Feb 2017 21:27:33 GMT"
}
],
"cookies": [],
"content": {
"size": 6397,
"mimeType": "image/png"
},
"redirectURL": "",
"headersSize": 433,
"bodySize": 0,
"_transferSize": 0
},
"cache": {},
"timings": {
"blocked": -1,
"dns": -1,
"connect": -1,
"send": 0,
"wait": 0,
"receive": 0,
"ssl": -1
},
"serverIPAddress": "204.2.145.184",
"connection": "989",
"pageref": "page_2"
}
{
"startedDateTime": "2017-02-10T21:23:38.412Z",
"time": 0,
"request": {
"method": "GET",
"url": "http://616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com/images/default-source/site-cdn/LoginLogo.png",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "image/webp,image/*,*/*;q=0.8"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, sdch"
},
{
"name": "Referer",
"value": "http://authentrip.com/"
},
{
"name": "Host",
"value": "616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com"
},
{
"name": "Accept-Language",
"value": "en-US,en;q=0.8"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
}
],
"queryString": [],
"cookies": [],
"headersSize": 428,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Fri, 10 Feb 2017 21:21:44 GMT"
},
{
"name": "Origin",
"value": "https://mycloud.rackspace.com"
},
{
"name": "Last-Modified",
"value": "Fri, 09 Dec 2016 05:10:48 GMT"
},
{
"name": "ETag",
"value": "ab904584a8e355da2fd0437065839e10"
},
{
"name": "Content-Type",
"value": "image/png"
},
{
"name": "X-Timestamp",
"value": "1481260247.52133"
},
{
"name": "Cache-Control",
"value": "public, max-age=349"
},
{
"name": "Content-Length",
"value": "6397"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Ranges",
"value": "bytes"
},
{
"name": "X-Trans-Id",
"value": "txbeec00752b6a4e1e9e3b5-00589e2ca4dfw1"
},
{
"name": "Expires",
"value": "Fri, 10 Feb 2017 21:27:33 GMT"
}
],
"cookies": [],
"content": {
"size": 6397,
"mimeType": "image/png"
},
"redirectURL": "",
"headersSize": 433,
"bodySize": 0,
"_transferSize": 0
},
"cache": {},
"timings": {
"blocked": -1,
"dns": -1,
"connect": -1,
"send": 0,
"wait": 0,
"receive": 0,
"ssl": -1
},
"serverIPAddress": "204.2.145.184",
"connection": "989",
"pageref": "page_3"
}
答案 0 :(得分:1)
事实上,Chrome确实为缓存中的第二个和第三个请求提供了响应。您需要查看entry.response.bodySize
属性。
HAR specification的相关摘录:
bodySize [number] - 收到的响应主体的大小(以字节为单位)。在来自高速缓存的响应的情况下设置为零(304)。如果信息不可用,则设置为-1。
还有一些有趣的HAR Viewer GitHub issue。他们使用下面的函数来确定是否从缓存提供了对请求的响应:
HarModel.isCachedEntry = function(entry) {
var response = entry.response;
var resBodySize = response.bodySize > 0 ? response.bodySize : 0;
return (response.status == 304 || (resBodySize === 0 && response.content && response.content.size > 0));
};