Compress Response
Overview
The Compress Response policy action enables you to improve the performance of your web applications by compressing HTTP response bodies returned by your upstream service.
If an HTTP request includes an Accept-Encoding
header, HTTP responses will be
automatically compressed and a Content-Encoding
response header will be
added. If the response was already compressed by your upstream service, ngrok
takes no action.
Example
Use this action config in your Traffic Policy
- YAML
- JSON
# snippet
---
actions:
- type: "compress-response"
config:
algorithms:
- "gzip"
- "br"
- "deflate"
- "compress"
// snippet
{
"actions": [
{
"type": "compress-response",
"config": {
"algorithms": [
"gzip",
"br",
"deflate",
"compress"
]
}
}
]
}
Request:
curl https://example.ngrok.app/api/v1
Result:
< HTTP/2 200
< content-encoding: gzip
< content-type: application/json; charset=utf-8
<compressed-body-here>