Why should I reuse XmlHttpRequest objects?

前端 未结 1 1609
遥遥无期
遥遥无期 2021-02-01 06:17

From what I understand, it\'s a best practice to reuse XmlHttpRequest objects whenever possible. Unfortunately, I\'m having a hard time understanding why. It seems that by try

1条回答
  •  深忆病人
    2021-02-01 06:26

    There are a whole host of problems relating to the number of open connections you can have at any one time; often this is imposed at a browser level as in all versions of Internet Explorer (IE6 allows 2, IE7 allows 2, IE8 allows 4), often this is imposed by server throttling and sometimes this is imposed by Internet Service Providers.

    If you have a large number of distinct XmlHttpRequest objects in one script, and for some reason some of their connections have not closed properly or have not been GC'd, you may run into difficulty opening new connections and have absolutely no idea what is going wrong.

    That and all of the reasons you mention.

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