What happens when we refresh a web page?

jack picture jack · Oct 27, 2009 · Viewed 13k times · Source

I was hoping if anyone can answer a fundamental question that I have regarding refreshing of a web page.

I have a dotnet webform where a user fills in some details and clicks submit. The code behind of the webpage has about 20 functions to perform.

Now assuming, when the user clicks the submit button the web page is executing the 5th function and meanwhile the user refreshes his browser;

What will happen to the already processing page? Will the page be terminated immediately? or will it be allowed to run till it executes the 20th function? or will the page running be destroyed and a new page created and sent to client?

Thanks for your answers.

Answer

Chuck Conway picture Chuck Conway · Oct 27, 2009

Once a request is made to the server from the browser the page is processed. Even if the user cancels or stops the request, the server continues to process the request. If the user reloads/refreshes the page, it's another request that will be executed in parallel with the first request.

Even in the case of PHP, the server isn't actively checking if the user has aborted the connection. The server only knows it's been aborted when it attempts to return the results of the request.

The internet is a disconnected environment. The server doesn't know anything about the browser. The only thing the server knows is a request has been made and it must fill the request.