# "X-Cache: Miss from cloudfront" as a result of a call to AWS API Gateway

**URL:** https://forum.serverless.com/t/x-cache-miss-from-cloudfront-as-a-result-of-a-call-to-aws-api-gateway/18277
**Category:** Serverless Framework
**Tags:** aws, api-gateway
**Created:** [February 1, 2023, 10:18am UTC](https://forum.serverless.com/t/x-cache-miss-from-cloudfront-as-a-result-of-a-call-to-aws-api-gateway/18277 "2023-02-01T10:18:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ImishinM](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/imishinm/32/7301_2.png) [@ImishinM](https://forum.serverless.com/u/ImishinM)
#### Post date: [February 1, 2023, 10:18am UTC](https://forum.serverless.com/t/x-cache-miss-from-cloudfront-as-a-result-of-a-call-to-aws-api-gateway/18277/1 "2023-02-01T10:18:16Z")

</div>

In a nutshell as a result of deploying a `serverless.yml` file, _AWS_ creates _API Gateway_ for _S3_ bucket and hidden _CloudFront_ distribution (you can’t have direct access to it via _AWS_ console), and when an _HTTP_ request goes through this pipeline a 200 response to it is provided with the `X-Cache: Miss from cloudfront` header. The same header with the same value repeatedly occurs despite using the _custom domain name_ or the _API Gateway Invoke URL._ (test were done in browser and POSTMAN):

 ![GET request to AWS APIGateway](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/3/3691475847a36306fdcbb3c7c982502804942894.jpeg)

Do you have any idea how I can rewrite the `serverless.yml` file for receiving a 200 response with the `X-cache:HIT` header, or at least what I have to improve via _AWS Console_?

This is the configuration that I deploy:

```auto
# serverless.yml

service: s3-blablabla-service

provider:
  name: aws
  stage: dev
  region: us-east-1
  environment:
    SERVICE_NAME: ${self:service}
  apiGateway:
    binaryMediaTypes: "*/*"

plugins:
  - serverless-apigateway-service-proxy
  - serverless-domain-manager
  - serverless-finch

custom:
  c3launchBucketName: "blabla-pl-${self:provider.stage}"
  c3scormBucketName: "blabla-crs-${self:provider.stage}"
  domainName: "${self:provider.stage}blablabla.bla.com" # Change this to your domain.
  basePath: "" # This will be prefixed to all routes
  apiGatewayServiceProxies:
    - s3:
        path: /pl/{myKey+} # use path param
        method: get
        action: GetObject
        bucket:
          # ${self:custom.c3launchBucketName}
          Ref: S3Bucket
        key:
          pathParam: myKey
        requestParameters:
          "integration.request.header.cache-control": "'public, max-age=31536000, immutable'"
    - s3:
        path: /crs/{myKey+} # use path param
        method: get
        action: GetObject
        bucket:
          # ${self:custom.c3scormBucketName}
          Ref: S3ScormBucket
        key:
          pathParam: myKey
        requestParameters:
          "integration.request.header.cache-control": "'public, max-age=31536000, immutable'"
  customDomain:
    domainName: ${self:custom.domainName}
    basePath: ${self:custom.basePath}
    stage: ${self:provider.stage}
    createRoute53Record: true
    autoDomain: true
  client:
    bucketName: ${self:custom.c3launchBucketName}
resources:
  Resources:
    S3Bucket:
      Type: 'AWS::S3::Bucket'
      Properties:
        BucketName: ${self:custom.c3launchBucketName}
    S3ScormBucket:
      Type: 'AWS::S3::Bucket'
      Properties:
        BucketName: ${self:custom.c3scormBucketName}

```

After the deployment I receive this result:

```auto
endpoints:
  GET - https://blablabla.execute-api.us-east-1.amazonaws.com/dev/pl/{myKey+}
  GET - https://blablabla.execute-api.us-east-1.amazonaws.com/dev/crs/{myKey+}

Service deployed to stack s3-blablabla-service-dev

Serverless Domain Manager:
  Domain Name: devblablabla.bla.com
  Target Domain: abrakadabra.cloudfront.net
  Hosted Zone Id: BARBARBAR

```

---

<div class="post-metadata">

### Author: ![jose-garrido-martine](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jose-garrido-martine/32/7755_2.png) [@jose-garrido-martine](https://forum.serverless.com/u/jose-garrido-martine)
#### Post date: [November 30, 2023, 10:31am UTC](https://forum.serverless.com/t/x-cache-miss-from-cloudfront-as-a-result-of-a-call-to-aws-api-gateway/18277/2 "2023-11-30T10:31:06Z")

</div>

Hello @ImishinM , did you find a solution? I’m facing exactly the same issue.
