feat: introduce TTL-based caching for Secrets Manager#337
Conversation
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success204 tests passing in 22 suites. Report generated by 🧪jest coverage report action from da20f1d Show full coverage report
|
There was a problem hiding this comment.
Pull request overview
This PR introduces TTL-based caching for AWS Secrets Manager–backed customer variables, enabling secrets to be refreshed after a configured time window while keeping a default cache duration.
Changes:
- Add a generic
TTLCacheutility (default TTL + optional per-entry TTL) and unit tests for it. - Switch Secrets Manager secret caching from a permanent in-memory map to
TTLCachewith a 5-minute default TTL. - Allow overriding the secrets cache TTL via a CloudFront origin custom header (
fpjs_proxy_secret_cache_ttl_ms) and thread it through the request path.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
proxy/utils/headers.ts |
Adds header parsing helper for secret cache TTL configuration. |
proxy/utils/customer-variables/secrets-manager/secrets-manager-variables.ts |
Plumbs optional TTL into Secrets Manager secret retrieval. |
proxy/utils/customer-variables/secrets-manager/retrieve-secret.ts |
Replaces map-based cache with TTLCache and supports per-call TTL override. |
proxy/utils/cache.ts |
Introduces the TTLCache implementation. |
proxy/test/utils/cache.test.ts |
Adds unit tests covering TTLCache behavior (expiry, custom TTL, null values, etc.). |
proxy/app.ts |
Wires TTL header parsing into SecretsManagerVariables instantiation. |
.changeset/cuddly-tires-tan.md |
Declares a minor release for introducing TTL-based secret caching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Introduces a reusable TTL-based in-memory cache and applies it to AWS Secrets Manager secret retrieval to enable default and per-request cache expiration control within the CloudFront proxy.
Changes:
- Added a generic
TTLCacheutility with per-item TTL override support. - Switched Secrets Manager secret caching to use
TTLCachewith a 5-minute default TTL and optional custom TTL. - Added a helper to read a secret-cache TTL value from CloudFront origin custom headers and wired it into request handling.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
proxy/utils/cache.ts |
New TTLCache implementation used as the shared caching primitive. |
proxy/utils/customer-variables/secrets-manager/retrieve-secret.ts |
Replaces Map-based cache with TTLCache and adds optional TTL parameter. |
proxy/utils/customer-variables/secrets-manager/secrets-manager-variables.ts |
Threads optional cache TTL through to secret retrieval. |
proxy/utils/headers.ts |
Adds getSecretCacheTtlMs helper for reading/parsing TTL from headers. |
proxy/app.ts |
Wires parsed TTL into SecretsManagerVariables construction per request. |
proxy/test/utils/cache.test.ts |
New unit tests for TTLCache behavior. |
proxy/test/utils/customer-variables/secrets-manager/retrieve-secret.test.ts |
Adds fake-timer-based test to verify cache expiry/refetch behavior. |
.changeset/cuddly-tires-tan.md |
Declares a minor release for the new TTL caching feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…tl' into bugfix/INTER-1894-secret-cache-ttl
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This pull request introduces support for configurable TTL (time-to-live) caching of secrets retrieved from AWS Secrets Manager in the CloudFront proxy.
Caching improvements:
TTLCacheclass inproxy/utils/cache.tsthat supports storing, retrieving, expiring, and clearing cached items based on a default or per-item TTL.retrieve-secret.tswith the newTTLCache, defaulting to a 5-minute expiry, and updated the cache logic to support custom TTLs.Secret retrieval and configuration:
SecretsManagerVariablesclass and its usage to accept an optional TTL value for secret caching, which is passed through to the cache. [1] [2] [3]getSecretCacheTtlMshelper inproxy/utils/headers.tsto extract the TTL value from thefpjs_proxy_secret_cache_ttl_msrequest header, allowing per-request cache configuration. [1] [2]