toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.5k stars 259 forks source link

Disable cache for templates #468

Closed AndreyMisnikov closed 2 years ago

AndreyMisnikov commented 2 years ago

Hello!

Is it possible to disable caching for templates? I use CompileRenderString(key, content, model). In my case, template can be changed, so I would like to overwrite cached template or disable caching at all.

I can use unique name for templates, but it will lead to memory leaks.

Thank you.

jzabroski commented 2 years ago

Just a guess. Look at how .UseMemoryCachingProvider() is implemented.

You just need to re-route caching to a no-op provider that always does a cache miss. Very miniscule performance penalty.