Client Templates Caching

Client Controls like the ClientBlockRepeater compiles Mvc Controls toolkit templates into knockout.js client templates. Client templates may be cached in memory to avoid the burden of processing and compiling them at each request.

Client templates caching may be enabled in each view/partial view by calling the Html Helper extension:

CacheClientTemplates(this HtmlHelper htmlHelper, string groupName)

groupname together with the template name identifies the template. Usually we have a groupName for each View or PartialView. However the same group may be shared by several Views/Partial Views if they share the same templates.

A template may be used in different places only if it is bound to the same ViewModel. Thus, for instance, a row template of an Items control may be shared by several controls in several pages only if the data type the row is bound to is the same in all controls.

As soon as the CacheClientTemplates helper is called in a View or Partial View that is returned by a controller all client templates created during the current request processing start to be cached and cached copies start to be used.

A Partial View called by another View inherit its father settings, while a Partial View returned directly by a controller must have its own settings.

Last edited Jun 22, 2014 at 11:07 AM by frankabbruzzese, version 1


No comments yet.