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:
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.
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.
Thanks for the invitation. The
duration
being 0 should mean that the cache is hit, and it is a long cache controlled bymax-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:Simply put,
responseStart
records the time when the browser initiates a resource request, but it must pass thetiming 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 theTiming-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 asstartTime
. I think this should be regarded as thestandard
Let’s take an example that is different from the specificimplementation
.