views:

205

answers:

1

Should i consider using ASP.NET Caching to cache query results on top of NHibernate 2nd Level Caching to improve performances ?

A: 

I think it's enough ot NHibernate 2nd level cache. There are no need for additional overhead by using asp.net caching to cache the same query results. But if you need ultimate performance you can cache your rendered pages and controls using IIS Kernel cache (native output cache). And also I recommend you to profile your application using NHibernate Profiler. It'll show cache misses and a lot of useful information about your queries with some good recommendations.

Edit:
NHibernate.SysCache2 uses ASP.NET cache and it is a bit slower because it supports SQL dependency-based expiration, meaning that it is possible to configure certain cache regions to automatically expire when the relevant data in the database changes.
Also you can try to cache your ViewModels. But if you can cache them then you also can cache the generated views which is much better and faster. And this article may be helpful for you - http://haacked.com/archive/2009/05/12/donut-hole-caching.aspx

zihotki
@zihotki : Yes but it seems (based on my own tests) that NH 2nd level cache (SysCache2) is pretty much slower than classic ASP.NET Cache using simple Key/Value cache items ...
Yoann. B