Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,128 | Comments: 45,550

filter by tags archive

The RavenDB caching solution

time to read 2 min | 265 words

One of the more interesting aspects of Raccoon Blog is that we have done absolutely no performance work on the blog at all. Nevertheless, one of the most common items of feedback was that it feels much faster.

There are actually two reasons for that. The first is that unlike relational databases, we model the data so loading each page is usually just a single query to the database. The second is that RavenDB has been designed to be very cache friendly.

Think about this, if you are using something like Entity Framework or Linq to Sql , you are basically out on your own with regards to a caching solution. With NHibernate, there is a builtin option, but that one is:

  • Disabled by default (rightfully so).
  • Easy to get wrong.
  • Usually takes me two hours to explain just this topic in my course.

In contrast to that, with RavenDB, caching is such an basic part of the system that we made it the default. Everything is cached by default (actually, we have multiple levels of caching, both on the client and on the server, but that is beside the point). The end result is that for the vast majority of cases, we only need to check if we are up to date, and all the data is already in the local cache.

I built this feature just for this scenario, but because it is on by default, I never actually thought about this, we just worked as we normally would, focusing on features, and RavenDB took care of the performance.



just a quick question on the cache strategy... i am assuming that client checks with the server to see if the content (or document) has been updated or is out-of-sync; (of course if this assumption is wrong then the question is moot)

working with this assumption, does the client actively pull the latest from the server or simply "clear itself out" awaiting the next request?

in other words, does the client update the content within the same request or does it simply send what it has currently and upon the next request update itself?

just curious

Sean Kearon

Yes, it is definitely faster!

João P. Bragança


iirc it's mostly done through etag caching. Every document gets an etag, which implemented here is a sequential guid. Client sends etag with the request, if they match then raven returns 304 not modified.


That is pretty sweet.

Matt Warren

There's more info on how RavenDB caches doc here http://ayende.com/blog/4748/ravendb-http-caching

Ayende Rahien

meisinger, It checks with the server whenever a query is made, to check if the query result (or the document being loaded) is already in the client cache. The way it work, you'll never get cached information that is out of date.

Chris Lawson

There are numerous external links to your (old) site to download Rhino Mocks for Silverlight. Is this port still available for download? I check the 'recent builds' link, but being from the older 3.5 version, it's not in the list.



Ryan Hoffman

I have to say, raccoonblog is clearly the fastest serving pages then any other blog engine I've ever seen. It's a great example of the power of RavenDB. All of these great features that RavenDB provides makes a really compelling argument for people to start jumping on board.

Ayende Rahien


Comment preview

Comments have been closed on this topic.


  1. The worker pattern - 14 hours from now

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats