How to Check if HTTP Responses Are Gzipped

How to Check if HTTP Responses Are Gzipped

Content compression is a key technique for improving web performance. It reduces the size of HTTP responses, enhancing load times and minimizing bandwidth usage. The most common compression method is gzip.

This article explains how to determine if a web server is returning compressed responses.


Why Compression Matters

Enabling compression on your server or CDN helps:

  • Speed up page load times, especially on slow networks.

  • Reduce traffic costs by transmitting smaller payloads.

  • Improve user experience and SEO scores.


How to Verify Content Compression

The quickest way to check if content is gzipped is to inspect the HTTP headers using curl.

🔍 Check with Compression Enabled

Use the --compressed flag to tell curl that it can accept compressed content:

bash

CopyEdit

curl -I http://edition.cnn.com/ --compressed

Sample response:

makefile

CopyEdit

HTTP/1.1 200 OK access-control-allow-origin: * cache-control: max-age=60 Content-Encoding: gzip Content-Type: text/html; charset=utf-8 ... Content-Length: 30340 ...

Content-Encoding: gzip confirms that the response is compressed.


🔍 Check Without Accepting Compression

Use the same curl command but omit the --compressed flag:

bash

CopyEdit

curl -I http://edition.cnn.com/

Sample response:

makefile

CopyEdit

HTTP/1.1 200 OK access-control-allow-origin: * cache-control: max-age=60 Content-Type: text/html; charset=utf-8 ... Content-Length: 137752 ...

In this case:

  • No Content-Encoding header.

  • Significantly larger Content-Length.

📌 This confirms the resource is uncompressed.


Summary

Method

Command

Compression Indicator

Method

Command

Compression Indicator

With Compression

curl -I URL --compressed

Content-Encoding: gzip

Without Compression

curl -I URL

No Content-Encoding header