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
perf(nuxt): invalidate getRouteMeta
cache on page contents change
#25514
perf(nuxt): invalidate getRouteMeta
cache on page contents change
#25514
Conversation
Run & review this pull request in StackBlitz Codeflow. |
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.
We definitely need to fix the ever-growing cache. But we can't cache based on the path as the path will stay the same even if the contents changes (e.g. if the user updates the meta and the site hot-reloads).
I know, this change uses a second cache to store the contents, if the contents have changed the metaCache entry is cleared. This is still indirectly using contents to cache metaCache, but doing so by caching contents by absolutePath separately in pageContentsCache. This way the keys aren't large, but the bigger gain is not having the cache grow on every change, only compared on every change. |
Ahh. Great! That sounds like a good solution. Will recheck it. |
absolutePath
as cache key in getRouteMeta
absolutePath
as cache key in getRouteMeta
absolutePath
as cache key in getRouteMeta
getRouteMeta
cache on page contents change
2f79eec
to
d133285
Compare
I thought I had those flaky scroll to top tests figured out π€¦ now it's failing in Ubuntu.. |
2bad97b
to
39c5727
Compare
39c5727
to
06bc1f5
Compare
π Linked issue
β Type of change
π Description
Instead of using file contents as key, we cache the contents separately using
absolutePath
as key. While I'm not sure if there is much performance gained by not using large strings as keys, using the contents as key will add an entry on every file change, so with the current implementation the cache will keep on growing during development as old entries won't be removed.(changed PR title to better communicate the change)
π Checklist