In the front-end monitoring, the loading time of cross-domain images is all zero, which response header should be added
Why is the loading time of cross-domain images in the front-end monitoring all zero, and which response header should be added - the answer is the timing bypass header, which is forced to zero when it is missing. The official documentation is clear: this header specifies which sources are allowed to see the attribute values obtained through the resource timing interface, otherwise these values will be reported as zero due to cross-domain restrictions. The point is that 'zero reading' does not mean that the resource did not take any time, but rather that the client is prohibited from telling you how much time it took.
Zero time does not mean that the resource did not take any time.
The resource timing interface splits a single request into several stages: redirection, domain resolution, connection and negotiation, sending the request, waiting for the first byte, and receiving the content. When the page accesses images across domains, these details are not exposed by default, and the segmented timing returned by the interface is uniformly set to zero, leaving only a few unrestricted items. As a result, the monitoring panel will show a misleading conclusion: the image timing is not visible, and it is considered to have no timing. Any attribution work on this data will be distorted.
What is this header allowing?
The permission that is allowed is read permission, not access permission. Whether the resource can be loaded is determined by the source strategy and the reference in the page; this header only determines whether the script can see the detailed time information. This determines that the risk of modification is very low: after adding it, the original images can still be obtained in the same way, but the monitoring can be split into stages. Conversely, omitting it will not cause the image display to be abnormal, but will only cause data loss - such problems are often discovered only when someone looks at the time distribution carefully.
How to write the value, how to handle multiple sources
Two writing methods. One is wildcard, all sources can read the timing; the other is a comma-separated list of sources, only listing the page addresses that need to read the data. The choice is very direct: if the monitoring collection end address is fixed and known, write a list; if the site is embedded by multiple parties or the source is difficult to enumerate, consider wildcard. Note that this header must appear in the response on the resource side, not on the domain where the page is located - images are on another domain, so the domain must return.
| Phenomenon | Reasons for data | Where to change | How to confirm after changing |
|---|---|---|---|
| Cross-domain image segment timing is zero | Unreleased timing read count | Response of the domain where the image is located | Resample and check if there are any non-zero values in each stage |
| Self-image has data, image service does not | Only released in the main domain | Image service or cache layer | Reproduce once by bypassing the cache and directly connecting to the source station |
| Unable to read after adding the header | The front-end layer filters out the header | Cache layer that generates the response | Compare direct connection and response after caching twice |
| Suddenly unable to read after going online | New response header definition at the same level inherits | Server configuration level position | Check if there are other header addition instructions written at this level |
Before attribution, confirm what the collection end can read
Before adding the header, it is worth checking the collection口径 first. The script on the page reads which indicator, whether it includes cross-domain attributes, and whether it distinguishes between same-origin and cross-domain when reporting, these three things determine whether you can see the numbers you want after adding the header. There is also an easily overlooked factor in the internal image link: the title automatically assigns images to the article, and after adding watermarks, the image address is often different from the page address. The images of this kind in AnQiCMS take an independent path and static resources, and when cross-domain timing is not allowed, it is the easiest to read as zero in the monitoring.
Don't treat it as performance optimization itself.
This header solves the visibility issue. After completion, there will be no change in the page loading speed, but you can see for the first time where the slow-down is: negotiation, waiting for the first byte, or receiving content. This step is very crucial for content sites, and the official criteria for page loading speed is significantly improved compared to traditional PHP programs, with a single machine capable of handling about 5 million PV. These descriptions refer to the server-side capabilities and do not mean that there are no bottlenecks in the specific page resource chain. When it comes to optimization, the only input that can be used is segmented data.
Common questions
What are the risks of wildcard writing? Answer: It exposes the time details rather than the content, the risk is not big, but it will provide site resource distribution information to scripts from any source, and if you can collect a list, collect a list.
What if you can't change the response of the third-party service for images? Answer: You can only add the service address to the exceptions of the collection口径, or change it to be reverse-proxied by your own domain, and add this header at the reverse proxy layer.
Is it enough to only supplement the image domain? Answer: Scripts, fonts, and stylesheets are also subject to this restriction, and any cross-domain resources that require segmented and time-consuming processing must be allowed in their respective responses.