When you are working with some more backend stuff of EPiServer, you are never really sure if you load it from the database or from the cache. Here are a few examples.
PageDefinitions
When you want to load a PageDefinition, the normal way would be:
EPiServer.DataAbstraction.PageDefinition.Load(int id);
The problem is that PageDefinition.Load goas straight to the database, no cache in sight. What you can do is to use the List-method:
EPiServer.DataAbstraction.PageDefinition.List(int PageTypeId);
cause this is actually cached.
So, theres a good way and a bad way:
// Loads from database
PageDefinition pageDef = PageDefinition.Load(
CurrentPage.Property[0].PageDefinitionID
);
// loads from cache
PageDefinition pageDefinition = PageDefinition.List(
CurrentPage.PageTypeID
).First(
pd => pd.ID == CurrentPage.Property[0].PageDefinitionID
);
Dynamic Properties
If you ever want to list all dynamic properties from a page, you get the same problem. When the most logical method goes to the database, you have to work around it again.
// Loads from database
DynamicPropertyCollection dynPropertiesDb =
DynamicProperty.ListForPage(
CurrentPage.PageLink
);
// Loads from cache
DynamicPropertyCollection dynPropertiesCache =
new DynamicPropertyCollection();
// List all from PageType = 0 = Dynamic proerties
PageDefinitionCollection pdc = PageDefinition.List(0);
foreach (PageDefinition pd in pdc)
dynPropertiesCache.Add(new DynamicProperty(
CurrentPage.PageLink,
CurrentPage.ParentLink,
CurrentPage.Property[pd.Name])
);
Conclusion
Sure, these two examples doesn't matter that much in a normal installation. But if you are working on something special it can be annoying. And, if you ask me, it demonstrates very clearly the "works good enough" mentality you sometimes hate in EPiServer. And don't get me started on why EPiServer can't cache a page version. So remember, Reflector is your friend. Always!