Ajax-intensive page: reuse the same XMLHttpRequest object or create new one every time?

前端 未结 1 1178
既然无缘
既然无缘 2020-12-10 18:02

I\'m working on some sort of online multiuser editor / coop interface, which will be doing a lot (as in, thousands) of ajax requests during one page lifetime.

What w

相关标签:
1条回答
  • 2020-12-10 18:10

    Create a new one when you need one. The GC will deal with the old ones once they are not needed anymore.

    However, for something like a cooperative editor you might want to consider using WebSockets instead of sending requests all the time. The overhead of a small HTTP request is huge while there is almost no overhead with a WebSocket connection.

    0 讨论(0)
提交回复
热议问题