开发者

What happens when a user presses stop in their web browser?

开发者 https://www.devze.com 2022-12-25 05:44 出处:网络
If a page is called that requires a lot of processing and the user clicks stop before the end, does the browser simply stop th开发者_StackOverflow中文版e request at the client side?

If a page is called that requires a lot of processing and the user clicks stop before the end, does the browser simply stop th开发者_StackOverflow中文版e request at the client side?

Or is a 'stop' message sent to the server, i.e. is the processing cancelled?


No message is sent to the server when that happens. When the user presses the stop button, the browser just halts the rendering of the page and ignore any further response= from the server.

If the request has already been sent to the server, the server will usually continue executing it. However, depending on the server's implementation, may detect the dropped connection. Meaning you can not rely on the fact that it will continue in every case.


Actually it kind of sends a "stop message" by closing the connection. This is true only if it is still waiting for output from the main request (not when finished downloading content and started loading images and stuff). So you can detect if the user presses the stop button OR there is some trouble with the connection, when you get connection closed message.

Here is some info on PHP's user manual: http://php.net/manual/en/features.connection-handling.php

On a side note - it always depend on the browser implementation and there is no certain way to be sure if the user pressed the stop button or the connection just dropped.


There's no "STOP" messages/requests defined in HTTP, since HTTP is stateless, and stopping a request would require you to know its ID. Quite naturally, as soon as HTTP request hits a server, it cannot be stopped from the outside world.


The server will still process the request. If you are using Visual Studio you can attach to the IIS worker processes to see that this is the case. Debug > Attach to Process

0

精彩评论

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

关注公众号