How do Web Servers work?
Web Server
The term web server can refer to #hardware or #software or both of them working together.
- On the #hardware side, a web server is a #computer that stores web server software and a website's files.
- On the #software side, a web server includes several parts that #control how the users' access hosted files.
Function
A web server connects to the #Internet and supports physical #data interchange with other devices connected to the web and delivers the content of its hosted websites to the end user's device.
HTTP Server
At a minimum, the webserver #software is an #HTTP server.
An HTTP server is software that understands #URLs and HTTP (the protocol your browser uses to view webpages) and can be accessed through the domain names of the websites it stores.
Static & Dynamic
- A #static web server consists of a computer with an HTTP server and it sends its hosted files as-is to your browser.
- A #dynamic web server consists of a static web server plus extra software, such as an app server and a database, and it updates the hosted files before sending content to your browser.
Process
At the most basic level, whenever a browser needs a file, it requests the file via #HTTP.
When the request reaches the correct web server (hardware), the HTTP server (software) accepts the #request, finds the requested #document, and sends the #response back to the #browser.
Hosting files
A web server has to store all #HTML, #CSS, and #JS files, images, fonts, etc. Technically, you could host those files on your own computer, but it's more convenient to store them on a dedicated web server because a web server is more #available, it's always connected to the #Internet, and it can have the same #IP address all the time.
HTTP
A #protocol is a set of rules for #communication between two computers. A web server provides support for HTTP (HyperText Transfer Protocol).
HTTP specifies how to transfer hypertext (linked web documents) between two computers and provides clear rules for how a #client and #server communicate.
Source: #ProgrammerPlus