Allow disabling or clearing of compile cache in SSR render
What problem does this feature solve?
We are using a NodeJS process for SSR rendering of vue snippets in an ASP.NET Core application. Over time we noticed that the memory of the NodeJS process increases, forcing us to terminate the process periodically. After some investigation we found that all templates and the resulting compiled functions are cached in a "compileCache" object that is used in the ssrCompile function.
While we try as much as possible to send templates to the process that are not changing dynamically, there are still reasons why over time templates change. For example when changes in the CMS occur or if the template contains data with some variation.
We are also employing our own render cache to avoid calling the NodeJS process for known templates.
This means that for our and similar use cases, the compile cache does not provide any benefit, will cache already cached data, and will over time cause out of memory problems.
I'm therefore proposing one of two options:
- Provide an option to disable the compile cache
- Provide and export a function to clear the compile cache
What does the proposed API look like?
Option 1:
compilerOptions: {
disableCompileCache: true
}
Option 2:
import { clearCompileCache } from '@vue/server-renderer'
I'm willing to contribute a PR implementing one of the two options, if accepted.
While this is probably not affecting many people, it is a potential issue for everyone using Vue to to render individual components from other backends and there is currently no good solution to avoid memory issues in this case.