Master Nginx Static‑Dynamic Separation: Boost Performance with Simple Config

Mike Chen explains how Nginx static‑dynamic separation works, detailing the concept, benefits, and a complete configuration that routes static files directly while proxying dynamic requests to an application server, thereby boosting response speed, resource utilization, and overall website performance.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Master Nginx Static‑Dynamic Separation: Boost Performance with Simple Config

Mike Chen introduces the concept of static‑dynamic separation in Nginx, a key technique for improving web performance by handling static resources and dynamic requests differently.

What is static‑dynamic separation?

It is a web architecture optimization that routes static files (HTML, CSS, JS, images) directly through Nginx while forwarding dynamic requests to an application server.

Benefits

Faster server response

Better resource utilization

Improved overall site performance and user experience

Nginx configuration example

server {
    listen 80;
    server_name mikechen.cc;
    # Static resource matching
    location /static/ {
        root /var/www/html;
        expires 30d;   # cache for 30 days
        access_log off; # reduce disk I/O
    }
    # Dynamic request forwarding
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

When a browser requests https://mikechen.cc/static/js/main.js, Nginx serves the file directly from the local disk, optionally with caching or CDN. For a request like https://mikechen.cc/user/info?id=123, Nginx proxies it to the backend (e.g., Tomcat) which generates the response and returns it through Nginx to the client.

This clear configuration enables efficient request routing and realizes the performance gains of static‑dynamic separation.

Diagram
Diagram
Architecture diagram
Architecture diagram
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ConfigurationWeb PerformanceNginxstatic-dynamic separation
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.