Static vs dynamic websites: where Nginx fits
Static content and dynamic content
Static delivery sends a representation that already exists, often a file such as HTML, CSS or an image. Dynamic delivery creates or selects a response at request time using application logic, user input or stored information. Static files can be updated over time; dynamic responses can be identical for many requests. The difference is how the response is produced, not whether the screen changes.
GET /about.html -> Nginx -> about.htmlGET /assets/site.css -> Nginx -> site.cssGET /api/stock -> Nginx -> inventory applicationThe first two paths can be served from files. The last one needs application logic if it must report current stock. A database is optional: the application may instead use an in-memory collection or another service.
Example: a static page
<!doctype html><html lang="en"> <meta charset="utf-8"> <title>About the bakery</title> <h1>Our bakery</h1> <p>Open Monday to Friday.</p></html>If the configured document root contains this file, a successful request for /about.html returns its contents. The text stays the same until the file changes. The server needs permission to read the file; its public URL need not be the same as the absolute disk path.
Example: an application response
An application could compute that JSON response from an inventory record. After a sale, the next request could report available: 2. Nginx can forward both requests to the application; it does not know the meaning of “available” unless additional application-specific logic has been implemented elsewhere. This is a fictional response, not an executed API.
A website can use both approaches
A browser can download a static HTML page and JavaScript file, then have JavaScript request dynamic data. That page is interactive even though its initial files were served statically. A dynamic response can sometimes be cached safely, but personalized information must not be shared between users. A reverse proxy does not automatically provide authorization, caching or database access.
Keep credentials, database files, backups and application source outside the public document root. Do not serve an entire project directory just because it includes an HTML file.
Practice: plan a small bookstore
Choose a delivery method for the store logo, an opening-hours page and the signed-in customer’s orders. The logo and hours page can be static files; the orders endpoint should use authenticated application logic. The application must check that the customer is permitted to see those orders. Your next chapter covers installation and how to prepare a safe local Nginx instance.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Static and dynamic delivery
Check the main concepts taught in this lesson.
A saved JavaScript file makes a page interactive after download. How can that file be delivered?
Which component should decide whether a customer may see their order records?
Which storage location is appropriate for database credentials?
The same dynamic endpoint returns identical JSON twice. What does that imply?
A bookstore needs a logo and a current signed-in order list. Which design fits?