Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Enable Gzip Compression on Nginx and Fix Missing File Types

A practical Nginx guide to enabling gzip, fixing incorrect Content-Type mappings, troubleshooting skipped responses, and verifying compression with active configuration and response headers.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable gzip in the shared http block, include Nginx’s MIME registry, and explicitly list the response types you want compressed. Nginx decides whether to compress from the response Content-Type, not from a filename extension. If CSS, JavaScript, JSON, SVG, fonts, XML, or WebAssembly are being sent with the wrong type—or the response is too small, proxied under a restrictive policy, or the gzip module is missing—compression will not appear in the response.

What Nginx gzip compression actually does

The ngx_http_gzip_module is a response filter: it compresses eligible responses with the gzip method as Nginx sends them. The feature is disabled by default. Turning it on is only the first half of the configuration; Nginx must also recognize the response’s MIME type and find that type in gzip_types.

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.

By default, Nginx compresses only text/html. A stylesheet named site.css is not compressed merely because its name ends in .css. Nginx checks the response header, such as Content-Type: text/css. If the file is returned as application/octet-stream, or as another unexpected type, a matching gzip_types entry will not help until the MIME mapping is corrected.

Clients also have to negotiate gzip. A request that does not advertise Accept-Encoding: gzip should receive an uncompressed response. When negotiation succeeds, the response should contain Content-Encoding: gzip. Setting gzip_vary on adds Vary: Accept-Encoding, telling shared caches that the representation depends on the client’s accepted encodings.

#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.

A practical baseline configuration

Put shared compression and MIME directives in the http block unless a particular virtual host or location intentionally needs different behavior. The following configuration enables runtime gzip, loads the standard MIME registry, skips very small responses, and covers common text, data, vector, font, and WebAssembly assets:

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    gzip on;
    gzip_vary on;
    gzip_min_length 1000;
    gzip_types
        text/plain
        text/css
        text/xml
        application/xml
        application/json
        application/javascript
        application/rss+xml
        application/atom+xml
        image/svg+xml
        font/woff
        font/woff2
        application/wasm;
}

gzip, gzip_types, and the related gzip directives are valid in http, server, and location contexts. Keeping the shared policy in http avoids a situation in which one server block works while another silently falls back to defaults.

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

What each directive controls

  • include /etc/nginx/mime.types;: Loads extension-to-MIME mappings used when Nginx sets Content-Type. The path can differ by package, so use the path present on your installation.
  • default_type application/octet-stream;: Supplies a fallback when no more specific mapping applies. It is not a substitute for adding a missing mapping; a generic binary type normally will not match your text-oriented gzip_types.
  • gzip on;: Enables runtime compression. The default is off.
  • gzip_vary on;: Adds Vary: Accept-Encoding to negotiated responses so caches do not treat compressed and uncompressed variants as interchangeable.
  • gzip_min_length 1000;: Sets a minimum response size in bytes for compression decisions. A validly typed response shorter than this threshold can remain uncompressed.
  • gzip_types: Adds MIME types eligible for compression. text/html remains included by default; listing additional values does not remove HTML.

Use semicolons exactly as shown. A syntax error, a directive in the wrong context, or a duplicate setting in a narrower block can prevent the intended policy from taking effect.

Why CSS, JavaScript, JSON, and SVG are not compressed

Most “gzip is not working” reports involve one of three separate checks: the client did not negotiate gzip, the response is below gzip_min_length, or the response Content-Type does not match the configured list. File extensions matter only indirectly, because they are used by the MIME registry to produce that response type.

Use the standard mappings first

The upstream MIME registry includes mappings for the common assets involved in web applications:

  • css maps to text/css.
  • JavaScript extensions map to JavaScript MIME values.
  • json maps to application/json.
  • svg maps to image/svg+xml.
  • woff maps to font/woff.
  • woff2 maps to font/woff2.
  • wasm maps to application/wasm.

Include the registry in the active http context, then make sure your gzip list contains the resulting MIME values. Correct extension mapping without a matching gzip_types entry produces the right Content-Type but still no compression. The reverse is also true: adding a MIME value to gzip_types cannot fix a response that is being labeled with the wrong type.

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

Add a missing extension mapping

If an asset has no entry in the registry, add its extension and MIME value to a types block, then add that MIME value to gzip_types. For example:

http {
    include /etc/nginx/mime.types;

    types {
        application/example-data datx;
    }

    gzip on;
    gzip_types application/example-data;
}

Replace application/example-data and datx with the actual type and extension required by your application. The important sequence is: define the extension mapping, confirm Nginx emits that MIME value, and then permit that MIME value in gzip_types.

Check for overrides

A later types directive or a narrower server or location block can override assumptions from the shared configuration. A default_type in the active block can also cause unknown files to be labeled generically. When the header is unexpected, inspect the complete loaded configuration rather than only the file you edited.

Verify compression from the client’s point of view

Do not infer gzip from an extension, a build artifact, or a browser’s network-size display alone. Test the negotiated response headers and the configuration Nginx actually loaded.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Identify the intended virtual host and location. Confirm that the request reaches the server and location block where you placed the directives. A different host, an included file, or a more specific location may be serving the asset.
  2. Send an explicit negotiation request. Use a client that includes Accept-Encoding: gzip. For a header-only check, a command such as curl -I -H 'Accept-Encoding: gzip' https://example.test/assets/site.css lets you inspect the response without downloading the body. Substitute your own host and path.
  3. Check Content-Type. It should be the expected value, such as text/css, application/javascript, application/json, image/svg+xml, font/woff2, or application/wasm. If it is application/octet-stream or another unexpected value, fix the MIME mapping or an overriding types/default_type directive first.
  4. Check Content-Encoding. A negotiated compressed response should include Content-Encoding: gzip. Its absence means a gzip decision filtered the response or the request did not negotiate gzip.
  5. Check Vary when enabled. With gzip_vary on, look for Vary: Accept-Encoding. This is particularly important when an intermediary cache serves the same URL to clients with different encoding support.
  6. Compare the response size with the threshold. If the body is shorter than gzip_min_length, test a larger representative file or lower the threshold deliberately. A missing Content-Encoding on a tiny response can therefore be expected.
  7. Validate before reloading. Run nginx -t. Only reload after the test reports a valid configuration.
  8. Inspect the expanded configuration. Run nginx -T to print the complete active configuration, including included files. Search the output for gzip, gzip_types, gzip_min_length, gzip_proxied, types, and default_type.
  9. Check the build. Run nginx -V and inspect the configure arguments. The gzip module depends on zlib and can be omitted with --without-http_gzip_module. If the module is absent, configuration directives for it cannot provide runtime compression.

Use a response large enough to cross the configured threshold and test an asset whose type is listed explicitly. This separates a policy problem from a size-related skip.

Small responses and the gzip_min_length trap

gzip_min_length is evaluated against the response size. Compression adds processing and framing overhead, so Nginx can intentionally leave small responses untouched. With the baseline value of 1000, a 400-byte JSON response can have the correct MIME type and still lack Content-Encoding: gzip.

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)

To diagnose this case, request a larger file of the same type or temporarily lower the threshold in a controlled environment. If compression appears after lowering it, the MIME and negotiation paths are working; the original response was simply below the configured minimum. Choose a production threshold based on your traffic and CPU budget rather than assuming every response should be compressed.

Compression through a reverse proxy

Responses coming from an upstream application may be subject to an additional policy controlled by gzip_proxied. The official administration example uses:

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.
server {
    gzip on;
    gzip_types      text/plain application/xml;
    gzip_proxied    no-cache no-store private expired auth;
    gzip_min_length 1000;
}

The parameters of gzip_proxied determine which proxied responses Nginx may compress. They refer to response and cache metadata, so inspect the upstream-related headers when troubleshooting:

  • Via
  • Cache-Control
  • Expires
  • Last-Modified
  • ETag

If a direct static-file request compresses but the same content through a proxy does not, compare these headers and the active gzip_proxied parameters. Adjust the policy intentionally: allowing compression for every proxied response without considering cache semantics can produce behavior you did not want, while a restrictive list can make otherwise eligible responses remain uncompressed.

Runtime gzip versus precompressed .gz files

There are two different mechanisms, and they should not be confused.

Approach How it works Operational trade-off Requirement
Runtime gzip gzip on compresses eligible responses as Nginx sends them. Simple deployment, but compression consumes CPU at request time. The HTTP gzip module and zlib support must be present.
Static gzip gzip_static looks for a matching prebuilt .gz file and serves it when the client supports gzip. Compression work can happen during a build or deployment, making output reproducible; you must keep compressed files alongside originals. The optional module must be built with --with-http_gzip_static_module.

gzip_static does not perform on-the-fly compression. It merely uses a file compressed beforehand by a compatible tool. If the matching .gz file is absent or the client does not support gzip, Nginx sends the uncompressed original. Generate the precompressed files with the gzip command or another compatible tool, and keep the original and .gz modification times aligned as recommended by the module documentation.

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

Choose runtime gzip when configuration simplicity and serving dynamically changing responses matter most. Choose precompression when you can generate assets during a build and want to move CPU work out of request handling. In either case, verify the response headers; a precompressed file still needs correct client negotiation and content-type behavior.

Choosing MIME entries safely

It can be tempting to use gzip_types * to make every response eligible. That is a blunt fix. Many binary formats are already compressed or gain little from gzip, including JPEG, PNG, MP4, ZIP, and similar formats. Compressing them can waste CPU and occasionally increase the payload.

Prefer an explicit list of text and data formats that benefit from compression. The baseline list covers plain text, CSS, XML, JSON, JavaScript, RSS and Atom feeds, SVG, common web fonts, and WebAssembly. Add another type only after confirming the response’s actual Content-Type and testing its size and CPU impact.

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

Security and performance considerations

CPU overhead

Runtime compression performs work while serving requests. The Nginx administration guidance notes that this adds processing overhead. Monitor CPU and latency after enabling it, especially on servers handling many concurrent dynamic responses. Precompressing stable assets can shift that cost to the build or deployment stage.

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

BREACH exposure over TLS

The official gzip module documentation warns that compressed responses sent over SSL/TLS can be subject to BREACH attacks. Compression can reveal information through response-size differences when attacker-controlled input is combined with secrets. Review whether sensitive, reflected content should be compressed over encrypted connections, and apply an application-specific mitigation rather than enabling compression indiscriminately.

Already-compressed formats

Do not add image, video, archive, or other already-compressed binary types simply because a filename extension is missing from the gzip list. The likely result is extra CPU work with no useful reduction. Keep these formats out unless measurement on your own assets demonstrates a real benefit.

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.

Common failure patterns and precise fixes

The header says application/octet-stream

This indicates that no specific MIME mapping is being applied, or that a later directive overrides it. Confirm the active mime.types include, inspect types blocks in nginx -T, and add the correct extension mapping. Then add the resulting MIME value to gzip_types.

The type is correct but there is no Content-Encoding

First verify that the request includes Accept-Encoding: gzip. Next compare the response size with gzip_min_length. If the request is proxied, inspect the metadata used by gzip_proxied. Finally, confirm that gzip on appears in the server’s effective configuration rather than only in an unused file.

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

One virtual host compresses and another does not

Check which server block matched the request and whether a more specific location changes gzip, gzip_types, types, or default_type. The directives can be placed at several levels, so a narrower block may produce a different result from the shared http policy.

gzip_static is configured but nothing changes

Confirm that the optional static module exists in the build, using nginx -V to inspect configure arguments. Then verify that a matching .gz file is present beside the original and that the client advertises gzip. Remember that this directive does not create the file or compress a response at request time.

The configuration test fails after adding gzip

Run nginx -t and read the reported file and line. Common causes include a missing semicolon, a directive placed outside an allowed context, a misspelled MIME value, or a build without the gzip module. Use nginx -T after correcting syntax to verify that the intended include order and overrides are present.

A deployment checklist

  • Load the correct mime.types file in the active http context.
  • Enable gzip on and set gzip_vary on if shared caches may serve the responses.
  • List the MIME values your text, data, vector, font, and WebAssembly assets actually emit.
  • Set gzip_min_length with awareness that smaller responses may be intentionally skipped.
  • Review gzip_proxied for reverse-proxy traffic and inspect the relevant upstream headers.
  • Keep already-compressed media and archive formats out of the list unless testing proves otherwise.
  • Run nginx -t before every reload and use nginx -T to audit the complete active configuration.
  • Use nginx -V to confirm zlib support, the gzip module, and, when applicable, --with-http_gzip_static_module.
  • Verify with a request that sends Accept-Encoding: gzip, then inspect Content-Type, Content-Encoding, and Vary.

When these checks agree, missing compression is no longer a mystery: the response is either correctly compressed, deliberately excluded by size or proxy policy, or clearly identified as a MIME or build configuration problem.

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.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.