84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
PS: The following timing neither queries the cache nor requests network resources. Why does this happen?
Following the voice in heart.
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:
duration
max-age
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:
responseStart
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.
On getting, the responseStart attribute must return as follows:
must
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.
timing allow check
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.
Timing-Allow-Origin
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.
responseEnd
startTime
standard
implementation
Thanks for the invitation. The
![](http://img.php.cn/upload/image/000/000/000/1ba28b50d32eeccde9dfc9a208f2e7d6-0.png)
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:
![](http://img.php.cn/upload/image/000/000/000/1ba28b50d32eeccde9dfc9a208f2e7d6-1.png)
![](http://img.php.cn/upload/image/000/000/000/ab1e6a0aaca943442fe808741a20fba1-2.png)
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
.