Skip to main content

Compression and ETag Headers

The ETag header is an identifier that shows whether the cached version of a file in the user's browser is the same as the version on the origin server. On each repeat visit, the browser sends the stored ETag value to the server; if they match, the server returns a 304 (Not Modified) response and prevents the file from being downloaded again. The Arvancloud CDN supports both strong and weak ETags.

A strong ETag, without the W/ prefix, shows that the file cached in the user's browser and the file on the origin server are byte-for-byte identical; for example, etag: foobar. A weak ETag, on the other hand, comes with the W/ prefix, for example etag: W/foobar, and shows that the file is semantically identical in meaning and content to the server version, but its bytes may differ, for example because of compression on the edge server.

When the client sends a request with the Accept-Encoding header, the CDN edge server compares the compression algorithm requested by the client with the algorithm the origin server used for the response. If they match, the edge server sends the origin server's response untouched, along with a strong ETag. If not, the edge server compresses the response with a different algorithm, or, if the origin server sent an uncompressed response, compresses it itself; in these cases, because the response bytes differ from the origin server's response, the edge server sends the ETag in weak form.

The following table shows the edge server's behavior for different combinations of the client's Accept-Encoding and the origin server's compression:

Client Accept-EncodingOrigin Server CompressionEdge Server Behavior
gzip, brGZIPSends the GZIP-compressed response with a strong ETag:
etag: foobar
gzip, brBrotliSends the Brotli-compressed response with a strong ETag:
etag: foobar
brGZIPDecompresses the GZIP response and sends a Brotli-compressed response with a weak ETag:
etag: W/foobar
gzipBrotliSends the Brotli-compressed response with a strong ETag:
etag: foobar
gzipNo compressionSends a GZIP-compressed response with a weak ETag:
etag: W/foobar
brNo compressionSends a Brotli-compressed response with a weak ETag:
etag: W/foobar
gzip, brNo compressionSends a Brotli-compressed response with a weak ETag:
etag: W/foobar

Note that if the origin server has already compressed the response and the client requested exactly the same compression algorithm, the edge server passes the response through untouched and keeps the strong ETag.