gpt4 book ai didi

javascript - 真实用户监控 : Standards for reliability

转载 作者:可可西里 更新时间:2023-11-01 01:19:31 24 4
gpt4 key购买 nike

在衡量网页性能时是否有可接受的信标数据丢失标准,以及计算这些丢失的标准方法?

许多用户没有支持 Navigator.sendBeacon 的浏览器,甚至那个 API 也不能保证无损报告。

似乎最有可能丢失的数据也是最有趣的数据,在某些方面——非常慢的页面、糟糕的互联网连接、不稳定的上传等。我想知道是否有已知的方法对此负责。

最佳答案

“可接受损失的标准”,这是一个笑话:),如果你引用W3.org正如他们所说,确保数据正确无误地提交是所有开发人员的问题。但是您会发现一些技术,希望在“没有受让人”的情况下一切都能正常工作:D。另请阅读 this

The Beacon specification defines an interface that web developers can use to asynchronously transfer small HTTP data from the User Agent to a web server.

The specification addresses the needs of analytics and diagnostics code that typically attempt to send data to a web server prior to the unloading of the document. Sending the data any sooner may result in a missed opportunity to gather data. However, ensuring that the data has been sent during the unloading of a document is something that has traditionally been difficult for developers.

User agents will typically ignore asynchronous XMLHttpRequests made in an unload handler. To solve this problem, analytics and diagnostics code will typically make a synchronous XMLHttpRequest in an unload or beforeunload handler to submit the data. The synchronous XMLHttpRequest forces the User Agent to delay unloading the document, and makes the next navigation appear to be slower. There is nothing the next page can do to avoid this perception of poor page load performance.

There are other techniques used to ensure that data is submitted. One such technique is to delay the unload in order to submit data by creating an Image element and setting its src attribute within the unload handler. As most user agents will delay the unload to complete the pending image load, data can be submitted during the unload. Another technique is to create a no-op loop for several seconds within the unload handler to delay the unload and submit data to a server.

Not only do these techniques represent poor coding patterns, some of them are unreliable and also result in the perception of poor page load performance for the next navigation.

关于javascript - 真实用户监控 : Standards for reliability,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34069736/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com