-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add option to disable Vento's cache when redundant or conflicting with other caching methods #71
Comments
Cache is always enabled to avoid recompile templates in loops. For example:
Without cache, the "show_number.vto" file is loaded and compiled 100 times. See #62 Does Eleventy's caching mechanism prevent this? |
Ah geeze, sorry I didn't see that other issue when I was writing this one. I actually don't know if Eleventy prevents this internally, but I'll do some tests. |
No problem! A simple way to test this is by overriding this function to avoid the cache. For example: class CustomEnvironment extends Environment {
async load(file: string, from?: string): Promise<Template> {
const path = this.options.loader.resolve(from || "", file);
// Remove query and hash params from path before loading
const cleanPath = path
.split("?")[0]
.split("#")[0];
const { source, data } = await this.options.loader.load(cleanPath);
return this.compile(source, path, data);
}
} |
So Eleventy does save the results of a compiled template for reuse, something that's documented here. To prove whether it's actually effective at handling the use case you've suggested, I have a couple of questions:
|
Also, running that throws an
|
Due you're on Node, you can edit directly the code of the package in the node_modules folder, which it's easier for debuging, instead of override functions or classes. This is only to test if removing the cache solve your problems. If it does, I'll include an option to disable the cache in Vento.
And about the error, yes, it's |
@oscarotero After doing some testing, I think I have a better idea of how Eleventy handles things:
Thanks for entertaining me and for the help with testing; I'll close this since it's on me to add to my integration. Cheers! |
Unsure where it might apply elsewhere, but this is definitely applicable to the Eleventy integration. Eleventy provides its own caching mechanism to prevent excessive template compilation, so in the context of
eleventy-plugin-vento
there's no need to cache the templates.Furthermore, myself and others (noelforte/eleventy-plugin-vento#10) have run into issues where the cache has to be cleared multiple times per run because of how Eleventy reuses template engines for other things like permalink compilation and computed data that's generated at runtime. I could write in logic to tune caching control and clear the cache before each compile operation but it seems easier to disable it entirely at a lower level.
The text was updated successfully, but these errors were encountered: