开发者

Sending simultaneous XMLHttpRequest

I'm writing a Goog开发者_如何学Cle Chrome extension that finds all titles on pages like this one and then sends a request to myanimelist.net to get the title's rating. The ratings are then inserted into the page.

A page contains about 100 titles, so the extension needs to perform 100 HTTP requests. Is it OK to do all 100 requests at once, or should I wait until one request is completed before sending the next one?

Is there a way to cache the results so that I don't need to redo the requests if the page is refreshed?


If you run 100 requests at once a destination server might block you, depending on its settings. I would rather send requests in small batches, like 5 at once.

You can cache results in localStorage if you need persistence between browser restarts, or just in a background page variable space, if you don't.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜