Description
What problem does this feature solve?
When using vue-router to navigate in a larger SPA, keep-alive is a very nice way to keep views/components that are frequently visited in the cache. When the instance of the component are cached, one avoids time and energy to reload it into memory (especially GPU related assets, which otherwise would cause unnecessary loading delay for the user).
In other words, keep-alive helps building a snappy and smooth experience for the user.
However, this also means that the components that have been visited are adding up in the memory, and can also consume some CPU even if they are never to be visited again by the user.
One can argue that the "max" property can limit this, but, I think there can be many different reasons to control this manually instead. In our specific case, we would like to control this for performance reasons (based on frequency of times the component is visited, time since last visit, how time consuming is the component to load, memory consumption of the component, etc.).
Right now we have managed to fix this with a fork, where we expose the function pruneCacheEntry(key: CacheKey) in KeepAlive.ts, but it would have been much better if this was a part vue itself.
What does the proposed API look like?
<keep-alive ref="aliveKeeper">
</keep-alive>
...
this.$refs.aliveKeeper.removeFromCache(myVueComponent);