Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

Nginx Proxying, Load Balancing, Buffering and Caching Explained

A practical, technically detailed guide to nginx reverse proxying, upstream load balancing, response buffering, and proxy caching—including directives, configurations, failure handling, and common fixes.
Length10 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Nginx can receive a client request, forward it to one or more application servers, regulate how responses are delivered, and serve reusable responses from its own cache. The key directives are proxy_pass for reverse proxying, an upstream block for load balancing, proxy_buffering and its buffer-size directives for response flow, and proxy_cache_path/proxy_cache for caching. Each solves a different bottleneck, and combining them safely requires explicit failure, freshness, and resource policies.

What nginx is doing between the client and your application

A browser or game client normally connects to nginx rather than directly to an application process. Nginx accepts the client connection, evaluates the request, and either serves a cached representation or opens a connection to an upstream server. It then relays the upstream response back to the client. This arrangement hides private application addresses, gives you one place for TLS and request policy, and lets several backend instances appear as one service.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The official nginx overview describes the software as an HTTP web server, reverse proxy, content cache, load balancer, TCP/UDP proxy server, and mail proxy server. The discussion here is about its HTTP proxying features. A reverse proxy is not the same as a forward proxy: the client is usually unaware of the backend, while nginx knows where the application servers are.

proxy_pass is the forwarding switch

Inside a location, proxy_pass sends the request to an upstream URL. The URI form matters. For example:

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
server {
    listen 80;
    server_name example.test;

    location / {
        proxy_pass http://app_backend;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

upstream app_backend {
    server 127.0.0.1:8080;
}

With an upstream group name, nginx chooses a member according to the group’s balancing method. Forwarded headers preserve the original host, client address, and scheme for applications that need correct redirects, logging, rate limits, or URL generation. Your application should be configured to trust these headers only from the nginx layer; blindly trusting client-supplied forwarding headers can make logs and access controls unreliable.

How nginx load balancing chooses an upstream

When no method is specified, HTTP upstreams use round-robin. Nginx sends successive requests across available servers in turn, subject to each server’s weight. Other methods change the selection rule to match connection load, response time, or session-persistence requirements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Method How selection works Good fit Important limitation
Round-robin (default) Distributes requests across the available servers in sequence; weights alter each server’s share. Backends with broadly similar capacity and request cost. It does not account for a server that is currently slower or has more active work.
least_conn Chooses the server with the fewest active connections; weights still influence distribution. Long-lived requests or uneven request durations. A connection count is only a proxy for actual CPU, queue, or downstream pressure.
least_time Considers measured response timing when selecting a server. Backends with materially different latency or changing performance. Availability depends on the nginx edition and configuration support; verify the feature in your deployment.
ip_hash Maps a client IP to a server to provide affinity across requests. Legacy applications that keep session state locally. Many users behind one NAT can concentrate on one backend, and clients whose addresses change can move between servers.
Weights A server with a larger numeric weight receives a proportionally larger share under methods that honor weights. Mixed hardware, staged capacity, or a canary with a deliberately small share. Weights distribute traffic; they do not by themselves measure health or guarantee a fixed percentage under every failure pattern.

Example upstream groups

upstream game_api {
    least_conn;
    server 10.0.0.11:9000 weight=3;
    server 10.0.0.12:9000 weight=1;
    server 10.0.0.13:9000 backup;
}

server {
    listen 80;
    location /api/ {
        proxy_pass http://game_api;
    }
}

Here the first server is intended to carry roughly three times the normal share of the second while both are eligible. The backup member is selected only when the primary members are unavailable. Test the resulting behavior with your real request mix; a weighted plan that is sensible for short API calls may be poor for streaming or websocket-like long connections.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Failure handling and health checks

Open-source nginx performs passive health checking. It observes communication failures while serving real requests and temporarily avoids an upstream that is failing. This is different from an application probe that asks a health endpoint before sending traffic. Nginx Plus adds active application health checks, activity monitoring, and dynamic upstream reconfiguration; those capabilities are not equivalent to the passive behavior in the open-source edition.

The proxy_next_upstream directive controls when nginx may retry a request on another member, such as after an error, timeout, or selected HTTP status. Retrying is safest for idempotent operations such as GET. Replaying a request that creates an order, spends currency, or mutates a save file can duplicate the action unless the application uses an idempotency key. Set retry conditions deliberately and log the original failure so a successful retry does not hide an unhealthy backend.

  • Use connection and read timeouts that reflect the endpoint’s expected duration; a short timeout can turn a slow but healthy operation into a retry storm.
  • Define an explicit policy for 500-level responses. A response generated by the application is not automatically safe to retry.
  • Drain or remove a server during planned maintenance rather than abruptly terminating active requests.
  • Monitor upstream response codes, connect time, response time, and active connections; a server that accepts connections but returns errors is not healthy from the user’s perspective.

Response buffering: what proxy_buffering changes

proxy_buffering is enabled by default. With buffering on, nginx reads the upstream response as quickly as it can, stores it in memory buffers, and sends data to the client while continuing to read from the application. If the configured memory buffers cannot hold the response, nginx can write part of it to a temporary file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Buffering decouples a fast application from a slow client. The upstream connection can be released sooner instead of remaining occupied while a user downloads over a congested connection. The trade-off is memory use and possible disk I/O, plus additional latency for workloads that need every upstream byte forwarded immediately.

The three buffer-size controls

  • proxy_buffer_size controls the buffer used for the initial portion of the response, normally the response headers. Headers that exceed this space can produce upstream-header errors.
  • proxy_buffers sets the number and size of additional buffers used for the response body. For example, proxy_buffers 8 16k; allocates eight buffers of 16 KiB each per proxied request, subject to the platform’s memory behavior.
  • proxy_busy_buffers_size limits how much buffered data can be in the process of being sent to the client while nginx continues reading from the upstream. It must be compatible with the other buffer settings.

Temporary-file behavior is governed by related proxy temporary-path and file-size directives. Keep the temporary directory on storage with sufficient capacity and monitor it; a configuration that fits in memory during normal traffic can fill a filesystem during a response burst.

When to disable buffering

Set proxy_buffering off; for endpoints where streaming latency matters more than upstream connection efficiency, such as server-sent events or a response that must be forwarded as it is generated. Confirm that the application sends appropriate flush-friendly output and that intermediary timeouts allow the stream to remain open. Disabling buffering globally is usually a mistake: ordinary API and page responses often benefit from the protection it provides.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
location /events {
    proxy_pass http://event_backend;
    proxy_buffering off;
    proxy_read_timeout 1h;
}

The long read timeout in this example is an application-specific choice, not a universal recommendation. Long-lived streams also need connection limits and observability so they cannot exhaust worker or upstream capacity.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How nginx proxy caching works

Proxy caching is a two-part configuration. proxy_cache_path creates a cache storage location and a shared-memory keys zone; proxy_cache selects that zone in a server or location. On a cache miss, nginx fetches the response from the upstream, stores an eligible representation, and returns it. A later request with the same cache key can be served without contacting the application.

http {
    proxy_cache_path /var/cache/nginx/game
        keys_zone=game_cache:20m
        max_size=2g
        inactive=30m
        use_temp_path=off;

    server {
        listen 80;

        location /assets/ {
            proxy_pass http://asset_backend;
            proxy_cache game_cache;
            proxy_cache_valid 200 10m;
            proxy_cache_valid 404 1m;
            proxy_cache_lock on;
        }
    }
}

The shared-memory zone stores cache keys and metadata; the files hold response bodies. The max_size and inactive values above are illustrative policy choices, not nginx defaults. Size them from the storage available on your host and the value of retaining each object.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Freshness comes from configuration and response headers

proxy_cache_valid assigns cache durations by response code. Upstream response headers can also control or override freshness: X-Accel-Expires is nginx-specific, while Expires and Cache-Control are standard HTTP mechanisms. Decide which layer is authoritative. Caching a personalized response without varying the cache key or bypassing the cache can expose one user’s data to another.

  • Bypass requests carrying authentication or session cookies when the response is user-specific.
  • Do not cache state-changing methods unless you have a narrowly defined, safe policy.
  • Include relevant host, scheme, query-string, and content-negotiation dimensions in the cache key when they change the representation.
  • Send an explicit cache status header during testing so operators can distinguish a hit, miss, bypass, and stale response.

Revalidation, duplicate fills, and stale service

proxy_cache_revalidate lets nginx validate an expired object with the upstream instead of downloading the entire representation when validators are available. proxy_cache_lock prevents many simultaneous misses for the same key from all filling the cache at once; other requests wait for the first fill according to the lock timeout settings.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

proxy_cache_use_stale permits serving an older cached response during selected upstream failures or update conditions. This can keep a catalog or static game asset available during an outage, but it deliberately serves data past its normal freshness. Limit stale conditions to content where that trade-off is acceptable, and make purge or versioned URLs part of your deployment process when an immediate update is required.

A practical configuration sequence

  1. Define the trust boundary. Put nginx on the public interface and keep application listeners private where possible. Decide which proxy headers the application trusts.
  2. Create and test the upstream group. Start with round-robin for comparable servers. Add weights, least_conn, ip_hash, or another method only when a measured requirement justifies it.
  3. Add proxy_pass and timeouts. Verify URI handling, forwarded headers, maximum request sizes, connect timeouts, and read timeouts for each endpoint class.
  4. Choose buffering per workload. Keep the default for ordinary responses. Disable it only for streaming or strict low-latency delivery, then monitor memory, temporary files, and open connections.
  5. Design the cache key and bypass rules. Exclude private and mutation responses before enabling a cache on a location.
  6. Set freshness and failure policy. Use response headers or proxy_cache_valid, then decide whether revalidation, cache locking, and stale serving are appropriate.
  7. Validate before reload. Run nginx -t, inspect the reported configuration path, and reload only after the syntax check succeeds. Exercise cache hits and misses, an oversized header, a slow client, and an intentionally stopped backend.

Common symptoms and fixes

Symptom Likely cause What to inspect
502 or 504 responses Connection refusal, upstream timeout, protocol mismatch, or all members temporarily avoided. Nginx error log, upstream address/port, connect and read timeout values, and backend logs.
Responses appear to come from the wrong user A personalized response was cached under a shared key. Cookies, authorization bypass rules, cache key dimensions, and upstream cache-control headers; purge affected objects immediately.
Streaming arrives in bursts Proxy buffering, application buffering, or an intermediary is holding data. Location-level proxy_buffering, application flush behavior, and response headers.
Upstream header-too-large errors The initial response buffer cannot hold the headers. proxy_buffer_size, cookie size, redirect headers, and whether the application is emitting excessive metadata.
Disk fills during traffic spikes Responses spill to proxy temporary files or the cache grows to its configured limit. Temporary path, cache path, filesystem capacity, max_size, and eviction activity.
One backend receives nearly all traffic ip_hash, a high weight, a backup-only setting, or a small client population. Upstream method and parameters, source-IP distribution, and active-member state.

Open-source nginx versus NGINX Plus

The open-source distribution provides the documented reverse-proxy directives, HTTP load-balancing methods, passive failure avoidance, buffering, and proxy-cache controls. NGINX Plus extends that foundation with application-level active health checks, richer activity monitoring, and on-the-fly upstream reconfiguration. Choose the edition based on whether those operational features are required; they do not change the need to design safe cache keys, retries, timeouts, and resource limits.

Choosing the right combination

  • Use plain round-robin and default buffering as a baseline for stateless, similarly sized application servers.
  • Add weights when capacity is intentionally uneven, and use least_conn when request duration varies substantially.
  • Use ip_hash only when the application genuinely requires client affinity; moving session state to a shared store is usually more resilient than pinning users.
  • Keep buffering on for normal web and API traffic; turn it off at the narrowest location that needs streaming semantics.
  • Cache immutable assets and public, repeatable responses first. Add authenticated or rapidly changing content only with explicit key, bypass, purge, and privacy rules.
  • Treat retries and stale serving as availability tools with correctness costs. Apply them to operations and content where duplicate actions or old data are acceptable.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.