DianaIonita / serverless-api-gateway-caching

A plugin for the Serverless framework which helps with configuring caching for API Gateway endpoints.
ISC License
136 stars 34 forks source link

Caching lambda proxy requests #67

Closed cbarlow1993 closed 4 years ago

cbarlow1993 commented 4 years ago

I have a lambda function which proxy's several requests under a /v1/pages/{proxy+} path.

Is it possible to set individual cache keys for each page underneath it?

Path examples.

/v1/pages/home /v1/pages/categories /v1/pages/categories/:categoryAlias

    handler: index.main
    events:
      - http:
          path: '/v1/pages/{proxy+}'
          method: any
          cors: true
          caching:
            enabled: true
DianaIonita commented 4 years ago

Hi @cbarlow1993,

You should be able to get per-page caching by specify the proxy as a cache key parameter like so:

    handler: index.main
    events:
      - http:
          path: '/v1/pages/{proxy+}'
          method: any
          cors: true
          caching:
            enabled: true
            cacheKeyParameters:
              - name: request.path.proxy