Everyone uses the Internet on a daily basis whether it is for checking emails, watching YouTube videos, uploading images and status on social media, or visiting a website on the browser.
But have you ever wondered what happens at the backend when entering the website URL and hit enter??
Let's do an activity-:
Step1- Open another tab and open any website (eg. your GitHub) and open the Developer tools (ctrl+shift+i), go to the Network tab and reload the page.
You would see something like this.
At the bottom you can see the number of requests made, size of file transferred. Also, you can see the headings like- name, status, type, the initiator.
What are these??
Name- It is the resource name returned by the server to the browser.
Type- It is the type of resource returned by the server (eg. JSON, HTML etc.)
Initiator- The file name that causes the request.
For example-: if you put an image URL in the <img>tag of HTML then the HTML file will make a request to particular URL for the image and display it.
Step2- Completed the above task lets move on to another, click on the first request and go to the response tab.
You will see an HTML document. This is the HTML document returned in the server response. The browser reads this HTML document and renders the website in the browser which we see. You can see how the website preview of this HTML Document by clicking the Preview tab.
Step3- Now click on the Headers tab
Here we can see the General and Response Headers.
General shows the details HTTP request.
1. Request URL - URL of the resource fetched
2. Request Method - denotes the action to be done. "GET" is for fetching some resource
3. Status Code - denotes how the server responded to the request.
4. Remote Address- This denotes the IP address of the Host and port number
Response Headers shows the server details like-:
1. content-encoding- shows the file character encoding.
2. content-type- shows the file type of the resource returned.
3. server- tells the server on which the server returning response is hosted.
and many more details.
Request methods tell the server what the browser wants to do by using the URL. Either get a resource, create a resource, modify or delete etc. Here are some request methods.
So next time you visit a website try to check the request method used by the browser for various activities.
Now let us move on to status codes. What are these??
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. They provide an acknowledgement to the request of the browser.
Responses are grouped into five classes:
- Informational responses (100–199) or 1xx class
- Successful responses (200–299) or 2xx class
- Redirects (300–399) or 3xx class
- Client errors (400–499) or 4xx class
- Server errors (500–599) or 5xx class
The common status response codes are-:
200- denoting the request was successful depending on the request method.
301- The URL of the requested resource has been changed permanently. The requested URL has been moved to a new address.
404- The server cannot find the requested resource.
500- The server has encountered a situation it doesn’t know how to handle.
There is a whole list to them and you can get the complete list of the codes.
That is just one half of the puzzle the other is API. But let's keep some of it for the next time.
Till then see you.
Connect with me on-:
and let's have some geeky talks.
To connect with us follow our social accounts and never miss an update :
Discord Invite: https://discord.gg/R3fpety