minor fixes

This commit is contained in:
Ilya Kantor 2020-08-14 19:34:16 +03:00
parent 9add5e76d5
commit 8eab7d6cc9

View file

@ -215,10 +215,10 @@ window.onunload = function() {
Normally, when a document is unloaded, all associated network requests are aborted. But `keepalive` option tells the browser to perform the request in background, even after it leaves the page. So this option is essential for our request to succeed.
It has few limitations:
It has a few limitations:
- We can't send megabytes: the body limit for `keepalive` requests is 64kb.
- If gather more data, we can send it out regularly in packets, so that there won't be a lot left for the last `onunload` request.
- The limit is for all currently ongoing requests. So we can't cheat it by creating 100 requests, each 64kb.
- We can't handle the server response if the request is made in `onunload`, because the document is already unloaded at that time, functions won't work.
- Usually, the server sends empty response to such requests, so it's not a problem.
- If we need to gather a lot of statistics about the visit, we should send it out regularly in packets, so that there won't be a lot left for the last `onunload` request.
- This limit applies to all `keepalive` requests together. So we can't cheat it by creating 100 requests, each 64kb.
- We can't handle the server response if the document is unloaded. So in our example `fetch` will succeed due to `keepalive`, but subsequent functions won't work.
- In most cases, such as sending out statistics, it's not a problem, as server just accepts the data and usually sends an empty response to such requests.