yosssi / ace

HTML template engine for Go
MIT License
836 stars 89 forks source link

Should I preload templates outside of request handlers? #74

Open basharov opened 7 years ago

basharov commented 7 years ago

In the examples I see that ace loads templates just inside the request handler, so that it runs this on each web request to this endpoint:

tmpl, err := ace.Load("index", "", nil)

Is it a good practice or should I load the template once before any request handler call then only run tmpl.Execute() inside the request handler?

Or does ace manage caching itself and I don't need to preload the template first and just leave as it is in the examples?

yosssi commented 7 years ago

@basharov Sorry for the late reply. Ace has a caching mechanism and you don't need to care about it. Ace caches templates by default. If you don't want to let Ace cache templates, you have to set the Ace DynamicReload option to true (again, it's false by default ).