Debugging with Dashbird: API Gateway Encoding not Enabled

When using services created by other people, it’s often neither obvious what they mean, let alone how to fix them. One of these error messages you might see when using Amazon API Gateway is “encoding not enabled”.

The first question here is, what kind of encoding does this error message refer to? The first thought might go into the video or audio encoding direction and lead to a dead-end since you probably didn’t send any audio or video files. The error message is confusing because it aims to compress your response payload.

What does “API Gateway Encoding not Enabled” mean?

Content-encoding will be disabled by default when you create a new API. So it’s very likely that you already have one or multiple APIs running that don’t use this feature.

Depending on your API responses’ size, disabled content-encoding can lead to needlessly high traffic. And outbound traffic from AWS can get expensive quickly.

How do you enable API Gateway content-encoding?

If you’re using the API Gateway console, you can simply enable content-encoding in your API settings.

Be aware that there are two “Settings” menu-items. First, you need to select your API, and then you select the settings of that API and not the general settings of the API Gateway service at the bottom.

Below, you can see the highlighted “Settings” menu-item for a gateway called “Endpoint.”

API Gateway settings
API Gateway settings

If you’re using the AWS CLI, the following command will update your API.

$ aws apigateway update-rest-api \

    –rest-api-id <YOUR_API_ID> \

    –patch-operations op=replace,path=/minimumCompressionSize,value=0

Replace <YOUR_API_ID> with the ID of the API you want to enable content-encoding for. If you choose a higher value than 0 for compression, all responses below that value won’t be compressed.

With CloudFormation, you have to set the MinimumCompressionSize property of your AWS::ApiGateway::RestApi resource. 

Why should you disable content-encoding?

In most cases, content-encoding doesn’t pose any problems. Compression algorithms are optimized these days, and almost all HTTP clients can work with compressed response payloads.

One reason to keep it disabled is performance. Compressing your responses doesn’t come for free. Minimal responses or binary responses often don’t compress very well, so you’re better off sending them uncompressed and save latency by removing a compression step.

Another reason is debugging. If you need to scan some network frames with a tool like WireShark for some reason, disabling content-encoding would give you more insights.

The final reason is the support of legacy browsers. If you work in a slow-moving company, the chances are that you have some ancient versions of the Internet Explorer floating around. This can lead to problems with compressed responses, especially when their content is an already zipped file.

Summary

Content-encoding is about the compression of your API responses, and you should consider enabling it to save money on outgoing AWS traffic.

If you have specific needs, like sending hard to compress binaries or only minimal response payloads, you can opt-out to squeeze out the last few milliseconds of latency.

You can also check if the content-encoding feature is enabled for API Gateway stages to compress API payloads with Dashbird. The Well-Architected Insights feature will give you a quick and easy understanding of how your current settings are impacting your whole system, what exactly is affected, and what to do about it:

api gateway encoding not enabled
Dashbird’s Well-Architected checks against API Gateway encoding

Further reading:

Debugging with Dashbird: Malformed Lambda Proxy Response

Building complex Well-Architected Infrastructures

AWS Well-Architected Framework in Serverless: Security Pillar

Read our blog

ANNOUNCEMENT: new pricing and the end of free tier

Today we are announcing a new, updated pricing model and the end of free tier for Dashbird.

4 Tips for AWS Lambda Performance Optimization

In this article, we’re covering 4 tips for AWS Lambda optimization for production. Covering error handling, memory provisioning, monitoring, performance, and more.

AWS Lambda Free Tier: Where Are The Limits?

In this article we’ll go through the ins and outs of AWS Lambda pricing model, how it works, what additional charges you might be looking at and what’s in the fine print.

More articles

Made by developers for developers

Dashbird was born out of our own need for an enhanced serverless debugging and monitoring tool, and we take pride in being developers.

What our customers say

Dashbird gives us a simple and easy to use tool to have peace of mind and know that all of our Serverless functions are running correctly. We are instantly aware now if there’s a problem. We love the fact that we have enough information in the Slack notification itself to take appropriate action immediately and know exactly where the issue occurred.

Thanks to Dashbird the time to discover the occurrence of an issue reduced from 2-4 hours to a matter of seconds or minutes. It also means that hundreds of dollars are saved every month.

Great onboarding: it takes just a couple of minutes to connect an AWS account to an organization in Dashbird. The UI is clean and gives a good overview of what is happening with the Lambdas and API Gateways in the account.

I mean, it is just extremely time-saving. It’s so efficient! I don’t think it’s an exaggeration or dramatic to say that Dashbird has been a lifesaver for us.

Dashbird provides an easier interface to monitor and debug problems with our Lambdas. Relevant logs are simple to find and view. Dashbird’s support has been good, and they take product suggestions with grace.

Great UI. Easy to navigate through CloudWatch logs. Simple setup.

Dashbird helped us refine the size of our Lambdas, resulting in significantly reduced costs. We have Dashbird alert us in seconds via email when any of our functions behaves abnormally. Their app immediately makes the cause and severity of errors obvious.