What does a web server do? How HTTP requests and static files are handled
Learn how web-server software receives HTTP requests, serves static files or forwards dynamic requests, and what to inspect when a resource is missing.
“Web server” can mean the computer that stores website files or the software that receives HTTP requests and returns files or other responses. In development, the software role is usually what matters. It can serve static files directly or forward requests that need dynamic processing to an application.
What a web server does
When a browser requests a URL, web-server software checks whether the requested path matches a file or a configured route, then prepares a response according to its settings. Files already created, such as HTML, images, and stylesheets, can be sent as-is. If no file or route handler is found, the server commonly returns an error. 404 Not Found usually means the requested resource was not found, but the actual status depends on server configuration and application behavior.
A dynamic request needs server-side code rather than a matching HTML file sent unchanged. For example, an application can look up a product in a database and create a JSON response. The web server may forward that request to the application and return its response to the client. Not every deployment runs the web server and application as separate programs.
A simple request sequence
A browser or other client sends an HTTP request with a URL and method.
The web server accepts the connection and request, then checks the URL, method, host, and configured route rules.
If the path matches a static file, the server can read it and return it. If caching is configured, it may use a stored response.
For a dynamic route, the web server may act as a proxy and pass the request to an application. The application processes rules and data and creates HTML, JSON, or another response.
The client reads the status and response content to display the page or choose its next action.
This is a general example. A deployment may divide or combine these tasks across a CDN, load balancer, proxy, web server, and application runtime. Proxies can also provide optional caching, authentication, logging, or load balancing.
Choosing a setup
**Static site:** A web server or CDN that serves HTML, images, and CSS unchanged may be sufficient.
**Dynamic site or API:** If the response varies with the user, route, or data, application code is needed. Check whether the web server forwards dynamic routes to an app or whether the app accepts HTTP directly.
**A proxy in front:** A front layer can centralize TLS settings, routing, static-file caching, or load balancing. If its configuration does not match the application, requests may be sent to the wrong path or arrive with unexpected headers. Use logs and responses to see how far a request got.
Troubleshooting a request
Use the browser's Network panel to inspect the request URL, method, status code, response headers, and body. If a static file does not appear, first check the URL path, file location, web-server path mapping, and permissions. If an API request fails, use logs and a request ID to determine whether the web server or application created the response. For a public API, curl -i https://example.com/path can show the status and response headers together. example.com is illustrative; replace it with the real address.
Do not infer the cause from a status code alone. A 404 commonly means a resource or route handler was not found, but some applications use it for other cases. Check the response body, server settings, and application logs to see where the request ended.
Sources: MDN: What is a web server? · MDN: Client-server overview · MDN: Overview of HTTP