HTTP/2, compression and caching on IIS and Nginx
Enable HTTP/2 over TLS, compress text correctly, set cache headers, and avoid double compression or caching secrets.
- Build
- 26100.33650
- Edition
- Standard / Datacenter
- Architecture
- x64
- Support
- Documentation (E1)
- Evidence
- E1Official documentation
- Verified
- 2026-10-29
- Page type
- Task
The short answer
Section titled “The short answer”- 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.
HTTP/2
Section titled “HTTP/2”IIS: HTTPS binding is the main requirement; HTTP/2 is negotiated via ALPN. Nginx:
listen 443 ssl;http2 on;Verify:
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.
Compression
Section titled “Compression”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.
Caching
Section titled “Caching”<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.
Verify
Section titled “Verify”curl.exe -I --compressed https://lab.example/assets/app.jscurl.exe -I https://lab.example/accountCheck content-encoding, cache-control, vary, and that the account page is not publicly cacheable.
Lab boundary
Section titled “Lab boundary”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.