Home  >  Q&A  >  body text

javascript - Use resource timing to observe resource access. What does responseEnd=0 mean?

PS: The following timing neither queries the cache nor requests network resources. Why does this happen?

typechotypecho2576 days ago704

reply all(1)I'll reply

  • 学习ing

    学习ing2017-06-12 09:33:53

    Thanks for the invitation. The duration being 0 should mean that the cache is hit, and it is a long cache controlled by max-age, so even the time for the server to return 304 is omitted. The information in the Network proves this:

    When caching is disabled, refresh the page to see the time spent on the network process:

    But another question comes, why so much time information is displayed as 0? At this time, you need to turn out the specification and check it out. For example, the definition of responseStart in the specification:

    On getting, the responseStart attribute must return as follows:

    1. The time immediately after the user agent receives the first byte of the response from relevant application caches, or from local resources or from the server if the last non-redirected fetch of the resource passes the timing allow check algorithm.

    2. zero, otherwise.

    Simply put, responseStart records the time when the browser initiates a resource request, but it must pass the timing allow check check, otherwise it returns 0. Jump to the definition and take a look. It actually checks whether it complies with the same-origin policy. If there is a cross-domain situation, it needs to be solved by adding the Timing-Allow-Origin header when the resource is returned.

    On our team’s blog, you can see the completeness of statistics when introducing source resources.

    Finally, let’s discuss the case where responseEnd is 0. The specification requires that non-source resources change information to return 0, but we have also seen that Chrome gives the same value as startTime. I think this should be regarded as the standard Let’s take an example that is different from the specific implementation.

    reply
    0
  • Cancelreply