Skip to content

HTTP/2, compression and caching on IIS and Nginx

Verified 1 min read

Enable HTTP/2 over TLS, compress text correctly, set cache headers, and avoid double compression or caching secrets.

Tested onStandard / Datacenter · Build 26100.33650 · x64
E1
Build
26100.33650
Edition
Standard / Datacenter
Architecture
x64
Support
Documentation (E1)
Evidence
E1Official documentation
Verified
2026-10-29
Page type
Task
  • HTTP/2 requires TLS in browsers; IIS enables it by default on modern Windows with HTTPS.
  • Compression is for text (HTML/CSS/JS/JSON/SVG), not images/video/zip.
  • Caching is a policy decision per path; do not cache authenticated HTML.

IIS: HTTPS binding is the main requirement; HTTP/2 is negotiated via ALPN. Nginx:

listen 443 ssl;
http2 on;

Verify:

Terminal window
curl.exe -I --http2 https://lab.example/

The status line should show HTTP/2. If it shows HTTP/1.1, check TLS/ALPN and whether a proxy is downgrading.

HTTP/2 is not HTTP/3; see the HTTP/3 page for QUIC.

IIS web.config:

<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="image/svg+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
</system.webServer>

Nginx:

gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
gzip_min_length 1024;
gzip_vary on;

Do not gzip already-compressed files; do not double-compress at the proxy and origin.

<location path="assets">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
</location>

For hashed assets, a long max-age + immutable is safe. For HTML, use no-cache or a short TTL so deploys are visible.

Terminal window
curl.exe -I --compressed https://lab.example/assets/app.js
curl.exe -I https://lab.example/account

Check content-encoding, cache-control, vary, and that the account page is not publicly cacheable.

E1. The lab served IIS/Nginx over HTTP and did not validate HTTP/2, compression or CDN caching. The config is the verification plan for Server 2025.

Sources