gpt4 book ai didi

node.js - iframe 中的 comet 服务器数据只是累积吗?

转载 作者:太空宇宙 更新时间:2023-11-03 22:56:34 24 4
gpt4 key购买 nike

我使用分块数据将 [script]dosomething()[/script] 标签推送到我的 comet 服务器的 iframe 中,但脚本标签只是继续永远累积。如何在每个脚本标记后删除它?

最佳答案

删除脚本标签

P.S:当你想删除脚本标签时,可能会遵循 Does comet server data in the iframe just accumulate?

我相信你应该close the connection after sometime (不好,请参阅 Does comet server data in the iframe just accumulate? )它会自动释放与该请求关联的内存。然后您当然需要重新连接。 This page甚至还说了些什么:

"Page Streaming" means the browser discovers server changes almost immediately. This opens up the possibility of real-time updates in the browser, and allows for bi-directional information flow. However, it's quite a departure from standard HTTP usage, which leads to several problems. First, there are unfortunate memory implications, because the Javascript keep accumulating, and the browser must retain all of that in its page model. In a rich application with lots of updates, that model is going to grow quickly, and at some point a page refresh will be necessary in order to avoid hard drive swapping, or a worse fate.

这建议重新加载页面,这也是一个选项。但我认为关闭该连接(iframe)并重新连接也可能有效。

Comet 有很多问题需要解决:

这就是为什么我再次建议您使用 socket.io(见下文),它可以解决所有这些废话。

Socket.io

我建议您使用socket.io相反,这是非常好的产品。是supported by all major browsers 。正如您所看到的,它支持多种传输(XHR、Websockets 等),并选择浏览器上可用的最佳传输以获得最佳性能。

关于node.js - iframe 中的 comet 服务器数据只是累积吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6637987/

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