October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Improve Your PageSpeed Score with Nginx Configuration

Learn which Nginx settings can improve PageSpeed—gzip, proxy caching, sendfile, tcp_nopush, try_files, and optional ngx_pagespeed—and how to measure gains without serving stale or private content.
Length12 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Nginx can improve the part of a PageSpeed result that happens between your application and the browser: compressing text, reusing safe responses, and serving static files efficiently. It cannot, by itself, repair oversized images, render-blocking JavaScript, third-party scripts, or slow application code. The reliable method is to run PageSpeed Insights or Lighthouse, identify failing audits Nginx can influence, change one area, and measure again.

This guide shows which directives to use, where they belong, how to avoid caching private content, and how to tell whether a change improved real user experience rather than only a lab score.

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.

What PageSpeed is measuring—and where Nginx fits

PageSpeed Insights combines two kinds of evidence: Lighthouse lab audits and field data from real Chrome users when enough data exists for the page and origin. Lighthouse gives a URL a series of audits and produces a report of opportunities and diagnostics. Its score bands are 0–49 Poor, 50–89 Needs Improvement, and 90–100 Good. The score guidance page accessed on 15 October 2026 also warns that a perfect 100 is extremely challenging and is not an expected universal target.

Nginx sits at the delivery layer. A configuration change can reduce bytes on the wire, prevent repeated trips to an origin server, or shorten the path used to read a static file. Those changes can improve transfer time, largest contentful paint, and other audits when delivery is the bottleneck. They do not alter the bytes generated by an image editor, remove JavaScript that blocks rendering, or make a slow database query faster.

#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.
Nginx approach What it changes Main cost or risk Use it when
Gzip response compression Reduces the size of compressible text sent to the browser Runtime CPU consumption; poor MIME selection can waste work HTML, CSS, JavaScript, JSON, XML, SVG, and other text responses are large enough to benefit
Proxy caching Reuses an origin response instead of generating it for every request Disk usage, invalidation complexity, and the risk of serving stale or private data The response is safe to share and has a clear freshness policy
sendfile and tcp_nopush Improves the kernel path used to transfer static files and packetize headers Benefits depend on the operating system, storage, and traffic pattern Nginx serves files directly rather than only proxying an application
try_files Checks local files and directories before routing a miss to a backend Incorrect fallbacks can create loops or hide application routes A site mixes static assets with a dynamic front controller
ngx_pagespeed Generates and serves optimized resources through a module Compatibility, build provenance, cache behavior, and operational maintenance You have validated the module and its generated-resource cache in your exact production stack

Measure before changing Nginx

Changing directives without a baseline makes it impossible to know whether a result came from Nginx, a different test run, or a changing backend. Treat PageSpeed as a measurement loop rather than a configuration checklist.

1. Capture a repeatable baseline

  1. Open PageSpeed Insights and test the exact public URL that matters. Test the mobile and desktop views separately; they can expose different bottlenecks.
  2. Record the performance score, the failing audits, and the opportunities and diagnostics listed in the report. Note whether a value comes from Lighthouse lab data or real-user field data.
  3. Repeat the run enough to see whether results are broadly consistent. Do not treat one unusually fast or slow run as proof of a configuration effect.
  4. Inspect the response headers and the Nginx access log for the tested resource. You need to know whether the response came from the origin, a cache, or a precompressed file.
  5. Change one material delivery behavior at a time, then run the same URL and viewport again. Keep a dated record of the directive, deployment, and before-and-after audit.

For a quick header check, request the URL without downloading the body:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -I https://example.com/

After editing configuration, validate syntax before reloading:

nginx -t

Only reload after a successful test, and watch the error log and response headers immediately afterward. A lower lab score after a change is a signal to investigate, not a reason to keep the change simply because it looks technically modern.

2. Select only audits Nginx can influence

  • Compression and transfer-size opportunities are candidates for gzip or precompressed files.
  • Repeated origin work and high time-to-first-byte for public responses are candidates for proxy caching.
  • Slow static-file delivery or inefficient file lookups are candidates for sendfile, tcp_nopush, and try_files.
  • Image-format, image-size, and responsive-image findings require changes to the image assets or application markup, not just the reverse proxy.
  • Render-blocking code, unused JavaScript, third-party scripts, and slow server-side computation require application or dependency work.

Compress text responses safely

Compressing responses often significantly reduces transmitted data. The documented Nginx pattern is to enable gzip, list the MIME types that should be compressed, set a minimum response size, and decide whether proxied responses should be compressed. Runtime compression uses CPU, so it should be aimed at text rather than applied indiscriminately to already-compressed media.

Use a narrow, explicit gzip policy

gzip on;
gzip_types text/plain text/css application/javascript application/json application/xml image/svg+xml;
gzip_min_length 1000;
gzip_proxied no-cache no-store private expired auth;

These directives can be placed in the http, server, or location context as permitted by Nginx. A common arrangement is to keep the general policy in http and override it only for an exceptional location. The MIME list should match the content your server actually emits; adding a type that is already compressed does not create a useful saving.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Understand each directive

  • gzip on; enables on-the-fly compression for responses that meet the other conditions.
  • gzip_types limits compression to named content types. HTML is handled by Nginx’s default behavior; the list above covers common CSS, script, data, XML, and SVG responses.
  • gzip_min_length 1000; avoids spending CPU on very small responses where headers and compression overhead can outweigh the saving. The value is measured in bytes.
  • gzip_proxied controls compression of responses received from a proxied server. The shown flags target responses marked no-cache, no-store, private, expired, or requiring authorization; confirm that this matches your cache and privacy policy.

Prefer precompressed files when you can build them

If your deployment process can create .gz assets, Nginx can serve those files with:

gzip_static on;

gzip_static makes Nginx look for a matching precompressed file; it does not perform runtime compression. This shifts CPU work to the build step, but every generated asset must be published and invalidated together with its uncompressed counterpart. Verify that your content negotiation and cache keys distinguish compressed and uncompressed variants correctly.

Check that compression is actually happening

Request a known text asset with an Accept-Encoding: gzip header and inspect the response:

curl -H 'Accept-Encoding: gzip' -I https://example.com/assets/app.css

Look for a gzip content-encoding header and compare the content length with an uncompressed request. Test HTML, CSS, JavaScript, JSON, and SVG separately; one location block or upstream header can override another. If CPU rises sharply, raise the minimum length, narrow the MIME list, or move more compression to the build pipeline.

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.

Cache public responses without leaking personalized data

Proxy caching can remove repeated origin work. When caching is enabled, the documented Nginx Plus behavior is to cache GET and HEAD responses by default and serve later requests from a disk cache. The performance benefit is real only when the cached response is safe for more than one requester and its freshness rules are correct.

A starting configuration

http {
    proxy_cache_path /data/nginx/cache keys_zone=mycache:10m max_size=1g inactive=60m;

    server {
        location / {
            proxy_cache mycache;
            proxy_cache_valid 200 302 10m;
            proxy_cache_valid 404 1m;
            proxy_cache_bypass $cookie_nocache $arg_nocache;
            proxy_no_cache $http_pragma $http_authorization;
            proxy_pass http://backend;
        }
    }
}

The cache path belongs in the http context. The cache name is then selected in the relevant server or location. In this example, successful and redirected responses remain valid for 10 minutes, while a not-found response is retained for one minute. The bypass variables allow a request carrying a no-cache cookie or query argument to skip reading an existing entry. The no-cache rule prevents storing responses when the request carries a pragma or authorization header.

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)

Decide what must never be shared

Do not copy the example unchanged for authenticated pages, account dashboards, carts, user-specific recommendations, or any response that varies by cookie, authorization, or user identity. A shared cache can return one person’s response to another person if the cache key and bypass policy do not account for personalization.

  • Start with genuinely public pages and versioned static or API responses whose contents are identical for all visitors.
  • Document how an editor, deployment, or data update invalidates the cache. A ten-minute validity window is not a substitute for an invalidation plan when changes must appear immediately.
  • Decide how query strings, cookies, authorization, and content negotiation affect the cache key. The example’s bypass and no-cache controls are safety boundaries, not universal rules.
  • Observe cache hits, misses, stale entries, disk usage, and origin load after deployment. A cache that fills the disk or serves stale pages is a production problem even if Lighthouse improves.

Test cache behavior as a state machine

  1. Request a public URL once and record the origin response and headers.
  2. Request it again and verify that the second request is served from the cache according to your logging or diagnostic header.
  3. Change the origin content, then confirm whether the old response remains for the documented validity period.
  4. Send the no-cache cookie or query argument and verify that the request bypasses the existing entry.
  5. Repeat the test with an authenticated request and confirm that private content is not stored or shared.

These checks matter more than a promised score increase. Caching can improve time to first byte for repeat requests while doing nothing for a first visit whose slowest resource is an image or a render-blocking script.

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

Serve static files with an efficient path

Enable direct file transfer

The F5 Nginx documentation describes sendfile as eliminating the step of copying file data into an intermediate buffer and enabling direct copying from one file descriptor to another. A typical static-file policy is:

sendfile on;
tcp_nopush on;

tcp_nopush works with sendfile to send response headers in one packet. The combination is most relevant when Nginx serves files directly. Measure on the operating system and storage used by your server; it is not a replacement for reducing the size of the files themselves.

Resolve files before invoking the application

location / {
    try_files $uri $uri/ @backend;
}

try_files checks whether the requested path maps to a file or directory. If neither exists, it routes the request to the named @backend location. This avoids sending every image, stylesheet, script, or favicon through the application while preserving a fallback for dynamic routes.

Define the named backend location to match your upstream design, and test both a real file and a missing route. A malformed fallback can create an internal redirect loop, return a false 404, or bypass application routing. Keep directory handling intentional: a trailing slash redirect, an index file, and a front-controller route are different behaviors.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Images and application code still dominate many audits

Google’s image guidance notes that images often account for much of a page’s downloaded bytes. It recommends choosing format, quality, resolution, and responsive delivery for each asset and device. Nginx can deliver an optimized image quickly, but it cannot decide the correct crop or recover bytes already present in an oversized source file.

  • Export each image at the largest rendered size actually needed, rather than shipping a camera-resolution original.
  • Choose an image format and quality level appropriate to the asset; a photographic hero and a flat icon do not have the same compression needs.
  • Provide responsive variants so a small phone does not download the desktop hero image.
  • Set dimensions in markup or CSS to reduce layout shifts while the resource loads.
  • Audit the largest contentful element separately from background images and below-the-fold media.

Likewise, Nginx cannot remove render-blocking application code, eliminate an expensive third-party tag, or repair a slow backend query. If the Lighthouse report points to those causes, route the work to the build, frontend, database, or dependency owner instead of adding more server directives.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Should you use ngx_pagespeed?

The ngx_pagespeed project documents an optional module configuration using pagespeed on;, a writable pagespeed FileCachePath, and location handlers for optimized resources. It also shows verifying the module with an X-Page-Speed response header.

This is a generated-resource system, not a simple switch equivalent to gzip or sendfile. Before production use, verify all of the following in the exact Nginx build and deployment model:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Module compatibility with your Nginx version, operating system, TLS stack, and other compiled modules.
  • Build provenance and how security updates are delivered for the module.
  • Write permissions, disk sizing, eviction, and backup behavior for FileCachePath.
  • How optimized resources are invalidated when source files, HTML, or application routes change.
  • Whether the module alters cache headers, content negotiation, or debugging in ways your CDN and browser cache understand.
  • A before-and-after audit on representative pages, including pages with personalization and pages that set strict security headers.

Use the response header only as a verification signal that the module handled a response. It is not evidence that the generated output improved a Core Web Vital. Keep the module only if measured gains outweigh the additional operational surface.

A rollout plan that limits regressions

  1. Baseline. Save PageSpeed Insights results for the target URLs, viewport types, failing audits, and field-versus-lab status.
  2. Fix the largest delivery defect first. If text transfer is large, test gzip or precompressed files. If repeat origin work is high and content is public, test proxy caching. If static resolution is wasteful, test sendfile, tcp_nopush, and try_files.
  3. Validate syntax and deploy narrowly. Run nginx -t, reload, and begin with one server, location, or small traffic slice.
  4. Check correctness before speed. Confirm status codes, content types, cookies, authorization behavior, cache headers, and compressed responses.
  5. Re-run the same audits. Compare the same URL and device class, then watch real-user field data as it accumulates. A lab improvement does not guarantee an immediate field improvement.
  6. Keep or revert based on evidence. Revert a change that increases errors, CPU, stale content, disk pressure, or private-data exposure, even if a single score moved upward.

Troubleshooting common Nginx/PageSpeed failures

The score did not change after enabling gzip

Check whether the audited resource is already compressed, smaller than gzip_min_length, served by a different location, or returned with a MIME type absent from gzip_types. Also check whether the audit’s largest transfer is an image or font rather than text. Compression cannot reduce bytes that are not compressible text.

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.

CPU usage increased after compression

Runtime gzip trades CPU for fewer transmitted bytes. Narrow the MIME list, increase the minimum size, or generate .gz files during the build and enable gzip_static. Recheck both server CPU and transfer time; saving a few bytes on tiny responses is rarely worth substantial CPU.

Cached pages show old or another user’s content

Disable caching for the affected location immediately, purge the entries, and inspect cookies, authorization headers, query strings, and cache keys. Reintroduce caching only for responses proven public, with explicit bypass and no-cache rules and a documented invalidation process.

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

Static assets return 404 or dynamic routes loop

Test the filesystem path, Nginx root, and the order of try_files arguments. Confirm that the named backend location exists and does not route back to the same try_files block indefinitely. Test a real file, a directory, and a route that only the application can generate.

The module header is missing

If you enabled ngx_pagespeed, verify that the running Nginx binary actually contains the module, that the directive is in the active configuration, and that the response passed through the location where the module is enabled. A missing X-Page-Speed header can mean the request bypassed the module rather than that optimization failed.

The practical order of operations

Start with measurement, then apply the smallest safe delivery change that addresses a failing audit. Use gzip for suitable text, proxy caching only for responses that are safe to share, and sendfile, tcp_nopush, and try_files to streamline static delivery. Treat ngx_pagespeed as a separate module decision with compatibility and cache obligations. Finally, fix image weight and application behavior at their source: Nginx can make good bytes travel faster, but it cannot make the wrong bytes disappear.

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.

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.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
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.