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

Razor.Parse with Caching does not work on Production #514

Open PvAsh opened 6 years ago

PvAsh commented 6 years ago

Hi I am using below code. to convert the template. I have around 100 templates and wan to cache them. it works absolutely fine on my Dev but does not work on production. For the same cacheSring I takes alomost 6000 ms to load the template and parse it. Any help would greatly appreciate.

Stopwatch sw = new Stopwatch(); sw.Start(); if (templateTypeId > -1) { string cacheString = templateTypeId.ToString(); Audit.Logging.Log("Cache hit!! Template : "+templateTypeId + ". Method is " + MethodBase.GetCurrentMethod().Name,null,"Dep Log"); document = RazorEngine.Razor.Parse(template, model, cacheString); } else { Audit.Logging.Log("No Cache hit!! Template : " + templateTypeId + ". Method is " + MethodBase.GetCurrentMethod().Name, null, "Dep Log"); document = Razor.Parse(template, model); } sw.Stop();

            Audit.Logging.Log("**Generating Template : Time taken" + sw.Elapsed.TotalMilliseconds + " milliseconds. Method is " + MethodBase.GetCurrentMethod().Name, null, "Dep Log");
            // no exception - no errors!
            errors = string.Empty;
PvAsh commented 6 years ago

Just to add I am using region Assembly RazorEngine.dll, v3.2.0.0