janodvarko / harviewer

HAR Viewer is a web application that allows visualizing HTTP Archive logs (HARs)
http://www.softwareishard.com/blog/har-viewer/
1.04k stars 184 forks source link

Some entries in Chrome 67 HARs are mistakenly displayed as cached #113

Closed gitgrimbo closed 6 years ago

gitgrimbo commented 6 years ago

Looks like HTTP/2 might be involved.

Sample snippets of an entry below.

We can see the timings all suggest that this isn't a cached entry, as does the _transferSize field. So maybe _transferSize is the only way of determining if a Chrome HTTP/2 entry is cached or not? The existing code tries to use a greater-than-zero bodySize as an indication of cached or not, but it is set to -1 here.

The cache object is empty, and so this is of no help.

  "request": {
    "method": "GET",
    "url": "https://www.google.co.uk/",
    "httpVersion": "http/2.0",
...
  "response": {
...
    "content": {
      "size": 222285,
      "mimeType": "text/html"
    },
    "redirectURL": "",
    "headersSize": -1,
    "bodySize": -1,
    "_transferSize": 66972
  },
  "cache": {},
  "timings": {
    "blocked": 0,
    "dns": 0,
    "ssl": 120,
    "connect": 213,
    "send": 0,
    "wait": 162.99999997857958,
    "receive": 201.00000005913898,
    "_blocked_queueing": -1
  },

See the request for https://www.google.co.uk/ is grey, as only a cached entry should be coloured. And see the connection bar has all the hallmarks of a non-cached request.

image

Whereas Firefox 60 gives a >0 bodySize:

  "request": {
    "bodySize": 0,
    "method": "GET",
    "url": "https://www.google.co.uk/?gws_rd=ssl",
    "httpVersion": "HTTP/2.0",
...
  "response": {
...
    "content": {
      "mimeType": "text/html; charset=UTF-8",
      "size": 201333,
      "text": "..."
    },
    "redirectURL": "",
    "headersSize": 744,
    "bodySize": 61083
  },
  "cache": {},
  "timings": {
    "blocked": 409,
    "dns": 0,
    "connect": 92,
    "ssl": 313,
    "send": 0,
    "wait": 165,
    "receive": 0
  },
  "time": 979,

More complete version of the Chrome entry above:

{
  "startedDateTime": "2018-06-01T19:52:34.486Z",
  "time": 577.0000000377186,
  "request": {
    "method": "GET",
    "url": "https://www.google.co.uk/",
    "httpVersion": "http/2.0",
    "headers": [
      {
        "name": ":method",
        "value": "GET"
      },
      {
        "name": ":authority",
        "value": "www.google.co.uk"
      },
      {
        "name": ":scheme",
        "value": "https"
      },
      {
        "name": ":path",
        "value": "/"
      },
      {
        "name": "upgrade-insecure-requests",
        "value": "1"
      },
      {
        "name": "user-agent",
        "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36"
      },
      {
        "name": "accept",
        "value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
      },
      {
        "name": "accept-encoding",
        "value": "gzip, deflate, br"
      },
      {
        "name": "accept-language",
        "value": "en-US,en;q=0.9"
      }
    ],
    "queryString": [],
    "cookies": [],
    "headersSize": -1,
    "bodySize": 0
  },
  "response": {
    "status": 200,
    "statusText": "",
    "httpVersion": "http/2.0",
    "headers": [
      {
        "name": "status",
        "value": "200"
      },
      {
        "name": "date",
        "value": "Fri, 01 Jun 2018 19:52:35 GMT"
      },
      {
        "name": "expires",
        "value": "-1"
      },
      {
        "name": "cache-control",
        "value": "private, max-age=0"
      },
      {
        "name": "content-type",
        "value": "text/html; charset=UTF-8"
      },
      {
        "name": "strict-transport-security",
        "value": "max-age=3600"
      },
      {
        "name": "p3p",
        "value": "CP=\"This is not a P3P policy! See g.co/p3phelp for more info.\""
      },
      {
        "name": "content-encoding",
        "value": "br"
      },
      {
        "name": "server",
        "value": "gws"
      },
      {
        "name": "x-xss-protection",
        "value": "1; mode=block"
      },
      {
        "name": "x-frame-options",
        "value": "SAMEORIGIN"
      },
      {
        "name": "alt-svc",
        "value": "quic=\":443\"; ma=2592000; v=\"43,42,41,39,35\""
      }
    ],
    "cookies": [],
    "content": {
      "size": 222285,
      "mimeType": "text/html"
    },
    "redirectURL": "",
    "headersSize": -1,
    "bodySize": -1,
    "_transferSize": 66972
  },
  "cache": {},
  "timings": {
    "blocked": 0,
    "dns": 0,
    "ssl": 120,
    "connect": 213,
    "send": 0,
    "wait": 162.99999997857958,
    "receive": 201.00000005913898,
    "_blocked_queueing": -1
  },
  "serverIPAddress": "172.217.7.227",
  "connection": "30233",
  "pageref": "page_1"
}