View | Modify | History

Performance

Some general tips for improving performance in N2-based websites

  1. Setting checkInstallationStatus="false" in the web.config will prevent all items being queried on application startup.
  2. Override the IsAuthorized method on your base Page/Part types AbstractPage and AbstractItem usually.
public override bool IsAuthorizedSystem.Security.Principal.IPrincipal user
{
return true;
}

This replaces the default N2 implementation of this method, which queries the database to find all permissions currently set for the current page.

NOTE: This is not an option if you use N2s permissions structure to secure your pages.

  1. Avoid using Find.Items.All, or using Find.Items.Where.Filters() without first narrowing down the result set with the other methods on this interface.
  2. The final option is to enable caching in the web.config. In the "database" section set caching="true"
This enables NHibernates 2nd level caching feature, and requires you to reference appropriate Caches DLL in your project or bin folder the default, NHibernate.Caches.SysCache2 should be included in the lib folder of the default N2 installation