Here is a snippet of the template rendering
var options = new TemplateOptions();
options.CultureInfo = System.Globalization.CultureInfo.CurrentUICulture;
options.MemberAccessStrategy = new UnsafeMemberAccessStrategy();
var context = new TemplateContext(model, options, allowModelMembers: true);
var template = _fluidParser.Parse(source);
return template.Render(context);
TemplateOptions should be reused. It is expensive to create new instances as caches are not reused. Register this as a singleton.
Template results from Parse should be reused. If the same templates are parsed then it makes sense to create a local cache of the parsed templates. A simple dictionary based on the source, or a key derived from it (filename, timestamp, ...) in a constrained IMemoryCache (time and size bound), would be ideal.
Here is a snippet of the template rendering
TemplateOptionsshould be reused. It is expensive to create new instances as caches are not reused. Register this as a singleton.Template results from
Parseshould be reused. If the same templates are parsed then it makes sense to create a local cache of the parsed templates. A simple dictionary based on the source, or a key derived from it (filename, timestamp, ...) in a constrainedIMemoryCache(time and size bound), would be ideal.