Antaris / RazorEngine

Open source templating engine based on Microsoft's Razor parsing engine
http://antaris.github.io/RazorEngine
Other
2.14k stars 578 forks source link

IIS template caching issue? #468

Open drowhunter opened 7 years ago

drowhunter commented 7 years ago

Hi i am using razor engine on my iis site to transform content on my main webpage

i have 2 templates (cshtml) files and im passing a static model

i just looked today and noticed that there are thousands of razor engine temp files being created every day

i was under the impression that when you call RunCompile that it cached the template. It seems like every hit to the page is recompiling a new dll

drowhunter commented 7 years ago

I just closer its worse than i thought, i cleared my temp directory and hit a page and two dlls are created, which is expected as i have two cshtml files that transform

then i hit the same page again and two more are created.

HotSpotSoft commented 7 years ago

@drowhunter Do you have debug enabled ?

DeeboSan commented 7 years ago

It caches the template in an in-memory collection that is only around for the life of the caching provider used by the IRazorEngineService instance. If each page request creates a new razor engine service you will get a new cache each time.