Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/proxy - cache miss on every request - NestJs #129

Open
claridgicus opened this issue Jul 15, 2023 · 1 comment
Open

/proxy - cache miss on every request - NestJs #129

claridgicus opened this issue Jul 15, 2023 · 1 comment

Comments

@claridgicus
Copy link

claridgicus commented Jul 15, 2023

Followed the examples that the package provides essentially to the letter and yet I'm unable to get the cache to actually return a hit.

APIG says the cache is active, and everything that is configured by the package seems to appear correctly but on this very simple example repo I am unable to get a cache hit.

I would have expected the apigateway header to tell me I have hit the cache, cloudwatch metrics confirms I'm getting cache misses.

Specifically building using typescript/nestjs which requires use of the:
path: /{proxy+}
and I assume also the base path setting
basePath: /dev

I have tried with and without basepath.

Here's my minimalistic repro repo
https://github.com/claridgicus/apigateway-cache-example-repro

@DianaIonita
Copy link
Owner

Hi @claridgicus,

Thanks for raising the issue and apologies for the delay.

The basePath variable is specifically used when the API Gateway is shared.
According to this plugin's docs:

If the shared gateway has a default base path that is not part of your endpoint configuration, you can specify it using the optional basePath setting.

I'm looking at your example repo and I don't see anything about a shared API Gateway.
If that's correct, then to keep /dev in your path, you can include it as part of your endpoint config:

functions:
  main:
    handler: src/main.handler
    events:
      - http:
          method: any
          path: /dev/{proxy+}
          caching:
            enabled: true
            ttlInSeconds: 5
            cacheKeyParameters:
              - name: request.path.proxy

Please let me know if you're still having problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants