开发者

Sending simultaneous XMLHttpRequest

开发者 https://www.devze.com 2023-03-28 06:01 出处:网络
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

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

精彩评论

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

关注公众号