Vue component caching with Redis - can not parse component into string #10516
Unanswered
AnJ-Github
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to get component caching working in Vue 2 (with Nuxt 2).
Right now we have typical LRU implementation from nuxt-multi-cache but we wanted to transition to using Redis (so that it would be outside of the pod, and we could easily invalidate it). I have basic setup ready, components are saved in Redis and are being read by Vue. But it break at the moment of parsing the data returned by Redis.
In
vue-server-renderer
there is this piece of code that receives Redis output:And it is breaking on this line:
saying that
res.components.forEach is not a function
So my implementation looks something like this.
Following this type declaration from Vue docs:
After some investigation I figured that the issue is occurring when we are saving data to Redis. It parses it and removes parts of the data.
I console logged data we get inside
set
method (the rendered component we get from Vue that should go into the cache for future use).And I got this:
So it seems that Vue broke its own type declaration, and instead of simple string we get some weird object with components, consisting of Set with functions.
And obviously this can not be parsed into string, so Redis client just removes it:
But the question now stands - how do I overcome that? I could not find a way to save those into Redis, but there should be a way to achieve component caching with Redis. Even Vue docs are saying that it should be possible:
https://v2.ssr.vuejs.org/api/#cache.
But documentation and resources on it are really scarce. Especially that this Vue version is ending its life soon.
Edit:
I think this might be an issue either in docs or in the source code. I created an issue in the repository: https://github.com/vuejs/core/issues/10523
Beta Was this translation helpful? Give feedback.
All reactions