blue-sky
blue-sky

Reputation: 53826

Is status code 200 sent after all code has been executed?

When a web page is being rendered is the http status code 200 sent before the page is rendered or does the page need to be fully rendered until status code 200 is sent ?

Upvotes: 0

Views: 78

Answers (4)

JustAnotherDeveloper
JustAnotherDeveloper

Reputation: 593

This is the schema of a general HTTP response.

Statuts line General header Response header Entity header -Empty line- -message body-

Next, the browser read all and renders the respons. The status code and the body are sended together but status code is the first line.

Read more: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html

Upvotes: 0

Oriol
Oriol

Reputation: 288260

According to the RFC 2616,

6 Response

After receiving and interpreting a request message, a server responds with an HTTP response message.

6.1 Status-Line

The first line of a Response message is the Status-Line, consisting of the protocol version followed by a numeric status code and its associated textual phrase

6.1.1 Status Code and Reason Phrase

The Status-Code element is a 3-digit integer result code of the attempt to understand and satisfy the request. These codes are fully defined in section 10.

So the status codes are sent at the beginning of the response, before the actual content.

Upvotes: 2

Ben Zotto
Ben Zotto

Reputation: 71018

The status code is unrelated to the page being rendered; the status code is returned by the server as a response to a request for a resource (like the HTML page). It's a way for the server to tell the browser "hey, I found the thing you asked for and here it is".

That arrives at the browser as one of the first pieces of information in the headers of the page data coming back from the server. What the browser does with this page data, and how and when it renders it, happens afterwards and is not connected with the server who has no knowledge of the browser.

Upvotes: 1

Rob
Rob

Reputation: 15160

The status code is the very first thing sent to the client browser before anything else. You can see this in your browser's developer tools "network" tab.

Upvotes: 1

Related Questions