---
title: X-Compress-Hint
summary: null
url: >-
  https://www.fastly.com/documentation/reference/http/http-headers/X-Compress-Hint
---

This non-standard header is used by Fastly to trigger compression of outbound client responses.  It can be set in a service configuration by writing VCL or Compute@Edge code.

### VCL

```vcl
set resp.http.X-Compress-Hint = "on";
```

### Rust

```rust compile_fail
response.set_header("x-compress-hint", "on");
```

### JavaScript

```javascript
response.headers.set("x-compress-hint", "on");
```

### Go

```go
response.Header.Add("x-compress-hint", "on")
```

If present in a response at the time it is served to a client, Fastly will inspect the `Accept-Encoding` value on the matching request, and if the client accepts compressed responses, will apply streaming compression to the response body and add a `Content-Encoding` header.  Regardless of whether compression is triggered, the `X-Compress-Hint` header will be removed.

Valid values are "on", "gzip" and "br".  "on" will select a compression algorithm automatically, preferring brotli if both are supported by the client.  In either case, the compression level applied is level 1.

In VCL services, it can be more efficient to compress responses before caching them, rather than compressing the content each time it is served.  See the VCL variables `beresp.gzip` and `beresp.brotli` or our [guide to compression on Fastly](https://www.fastly.com/documentation/guides/concepts/compression/) for more details.

In services that use [shielding](https://www.fastly.com/documentation/guides/concepts/shielding/) or [service chaining](https://www.fastly.com/documentation/guides/concepts/service-chaining/), the client may be Fastly.  If you intend to apply the compress hint only when a response is to be finally served to the end user, use the `Fastly-FF` header in Compute@Edge services or, in VCL, the `fastly.ff.visits_this_service` variable.

Any `Content-Length` header present on the response is removed when the response is compressed, since Fastly is unable to determine what the content length is at the time the header block is transmitted.  Any `ETag` header is preserved.
