DianaIonita/serverless-api-gateway-caching

Caching lambda proxy requests

Closed this issue · 1 comments

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

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