---
title: "Ensure API gateway caching is enabled"
canonical: "https://kb.cynergy.app/space/MD/991789690/Ensure%20API%20gateway%20caching%20is%20enabled"
format: markdown
---
Cynergy Policy ID: CYN_AWS_GENERAL_128  
Severity: LOW

# API gateway caching is disabled

# Description

This checks that all methods are in an Amazon API Gateway stage to ensure that they have caching enabled.  
As AWS puts it "With caching, you can reduce the number of calls made to your endpoint and also improve the latency of requests to your API" so if you need to minimize those, this will help.  
See the AWS docs for more information: [https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html) 

# Fix - Runtime

To configure API caching for a given stage:

- Go to the API Gateway console.
- Choose the API.
- Choose Stages.
- In the Stages list for the API, choose the stage.
- Choose the Settings tab.
- Choose Enable API cache.

Wait for the cache creation to complete.

# Fix - Buildtime

## Cloudformation

- **Resource:** AWS::ApiGateway::Stage
- **Argument:** CacheClusterEnabled

CacheClusterEnabled

```
AWSTemplateFormatVersion: "2010-09-09"
Resources:
  CacheTrue:
    Type: AWS::ApiGateway::Stage
    Properties:
      StageName: test
      Description: test
      RestApiId: test
      DeploymentId: test
+      CacheClusterEnabled: true

```

# Fix - Build time

## Terraform

- **Resource:** aws_api_gateway_stage
- **Argument:** cache_cluster_enabled

aws_api_gateway_stage.examplea.tf

```shell
resource "aws_api_gateway_stage" "examplea" {
  deployment_id = aws_api_gateway_deployment.stage_api.id
  rest_api_id   = aws_api_gateway_rest_api.api.id
  stage_name    = "example"
  cache_cluster_enabled = true
}
```