-
- Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(nuxt): Instrument server cache API #17886
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
base: awad/js-1016-nuxtnitro-instrument-kv-storage-instrumenting-unstorage
Are you sure you want to change the base?
feat(nuxt): Instrument server cache API #17886
Conversation
size-limit report 📦
|
64e5814
to 42ef2c7
Compare 09e73ad
to 4f26f70
Compare * Checks if the cache entry is a response cache entry. | ||
*/ | ||
function isResponseCacheEntry(key: string, _: CacheEntry): _ is CacheEntry<ResponseCacheEntry & { status: number }> { | ||
return key.startsWith('nitro:handlers:'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be checked with CACHED_FN_HANDLERS_RE
here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not here no, we want to be able to distinguish between cachedFunction
and cachedEventHandler
cached entries here, the regex detects if it is either.
The reason for the distinction is we want to apply more checks if it is a cached response entry since Nitro employs more checks in that case that would determine the cache validity.
ab3ecc1
to d943f7d
Compare 1c23b89
to f2ad9e7
Compare
Adds Nitro/Nuxt Cache API instrumentation by building upon the storage instrumentation in #17858 since both use
unstorage
under the hood.How it works
Nitro injects the cache storage on either
cache:
or the root mount depending on user configuration, also in production thecache
storage is placed on the root mount unless the user configures it explicitly to redis or something else. We instrument both mount drivers to cover other cache use cases.I made sure to add e2e tests as well for
cachedEventListner
andcachedFunction
calls which are the main ways to use the Cache API.This PR depends on the storage PR #17858.