What is a Web Server
A web server is a crucial component of the internet infrastructure responsible for delivering web content to users. Basically it is a software that uses HTTP requests from clients (often web servers) by serving web pages or other content. To better understand this topic we will delve into what a web server does and how it functions
The Request-Response Model
At the heart of web server functionality lies the request-response model. This model is a fundamental concept that describes how web servers and clients (like web browsers) communicate over the internet. Lets explore the procedures used in the process of communication
Initiation of a request: The process begins when a user enters a URL in their browsers or clicks a link, consider typing, google.com, on your browser. This action prompts the browser to send an HTTP request to the appropriate web server.
Processing the Request: Upon receiving the request, the web server processes it. This could involve several tasks such as:
i. Identifying the requested resource (e.g, a webpage, image or video).
ii. Executing any necessary server-side scripts (like PHP or python scripts) to generate dynamic content.
iii. Interacting with databases to fetch relevant data.
Generating a Response: Once the server has processed the request, it generates a response. This response includes the HTML document which was the requested content
Delivering the Response: The server sends the response back to the client, where the browser interprets it and renders the page for the user to view it.
But have you ever thought about how it works
When we request (clicks) for a page/button there is an associated IP address for the domain name. Example: Domain name: google.com and IP address: 8.8.8.8
Domain names and IP addresses are always unique. An IP address is for the computers, servers, and other devices to identify and communicate with each other over the network. So domain name can be said as a readable and easy-to-remember format of an IP address for humans.
So the requests reach the web server and respond back in the same way by sending back the requested page or performing some action. If it doesn't exist we see some error (404 error). Then we see the web page or video start playing.
Types of Web Servers
Now that we have a basic understanding of web servers, lets take a short tour on some of the popular web servers common today
1.Apache 2 Server
It is an open source and one of the servers widely used. It is developed by Apache Software Foundation. It completed 25 years in Feb 2020. It can also be used cross-platform means can be supported by windows, Linux, mac, etc. It is used for process requests.
2. Nginx
It is also open source and useful in scalability. It helps to increase performance due to managing multiple requests at the same time and also has some advanced features.
Web Hosting
Well we have looked at some of the popular web servers but how do we actually access them? That’s where web hosters come in. A web hoster provides access to a web server for our website to store files related to the website they are hosting. Examples: databases, files, images, code, etc. These code files include content written in HTML, CSS, JavaScript, React, etc all files to run the website. Some of the popular web hosters are Bluehost, Hostinger, Bigrock and GoDaddy
What about the website that runs on localhost on our PC?
Well for that we have amazing plugins by Ritwick dey - Live server which is useful while developing and supports live reloads of the web page. There is also another plugin Live server Preview by negokaz which opens the browser tab side-wise and also supports live reload of the web page.