Try our conversational search powered by Generative AI!

EPiServer Commerce cache

Vote:
 

A quick Google search didn't give back any info on how EPiServer Commerce uses caching for its catalog and entries. My question is is there a tech-note or similar I can look at to learn more about EPiServer Commerce's caching functionality? What I'm wondering about:

  • What gets cached and for how long
  • How is the cache invalidated and what causes it to be invalidated
  • Any tips on what we as developers should cache ourself and what is cached out of the box
  • If I'm caching myself how can I have a dependency on EPiServer Commerce, entries in the catalog

Thanks!

Frederik

#59345
Jun 01, 2012 16:44
Vote:
 

Caching for each subsytem is configured in the confiuration file that goes with it.  For catalog, you will want to refer to ecf.catalog.config in the configs folder of your site.

<Cache enabled="true" collectionTimeout="0:1:0" entryTimeout="0:1:0" nodeTimeout="0:1:0" schemaTimeout="0:2:0"/>

    

The collection timeout responds to an entry array, and entry responds to a single entry.  What is actually cached is the CatalogEntryDto.  Since the Entry object is created from the dto we chose to cache to the dto.

 

The cache is invalidated when it hits the cache timeout specified above for the request type.  It can also be invalidated if the whole catalog cache is cleared by calling CatalogCache.Clear().  Another way to invalidate for a particualr entry is to remove the key using CatalogCache.Remove(key).  When calling CatalogContext.SaveCatalogEntry, it will automatically remove the entry from the different cache keys by calling

CatalogCache.RemoveByPattern("^" + CatalogCache.CreateCacheKey("catalogentry"));
            CatalogCache.RemoveByPattern("^" + CatalogCache.CreateCacheKey("catalogentries"));
            CatalogCache.RemoveByPattern("^" + CatalogCache.CreateCacheKey("catalogitems"));

    

Some customers will cache the entry objects themselves rather than the DTO.  Some customers that were using memcached before using episerver commerce have also used memcahced to store entry objects and will have the memcahced object update every so often.

 

If you want to hook into the catalog event system to create a depency for you own cache you can look at the following link.

http://sdk.episerver.com/commerce/1.1.2/Content/Developers%20Guide/Catalog%20System/Catalog%20How%20To%20Code%20Samples/Writing%20Event%20Handlers.htm

 

 

 

#59383
Edited, Jun 04, 2012 21:07
Vote:
 

How about when running multiple servers? Will it only invalidate the local cache of that server? Thanks for your answers Mark, helps alot :).

Frederik

#59385
Jun 04, 2012 23:37
Vote:
 

Only for the local cache of the server.  There are improvements to the caching layer on the roadmap for commerce. 

#59386
Jun 05, 2012 0:16
Vote:
 

I find the topic interesting but i still have questions after reading your post Mark. At the productdetail page. The first time i hit any product it takes relativly long time to load. But for subsequent requests its fast. To me it seems like its the complete catalog that is cached, and not what i request specificly. I am kindda worried cause we have below 100 items in the catalog for now ...

We use

CatalogContext.Current.GetCatalogEntry(code, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));

to fetch the entry. The entry has multiple variants.

#59433
Jun 08, 2012 15:04
Vote:
 

What do you mean when you say the first time it takes a long time.  After the app pool starts each product detail page takes a long time or just one.  IS this after compiling the solution.  

#59462
Jun 12, 2012 23:50
Vote:
 

I investigated the problem a little deeper. I put on a MVCMiniProfiler. Our problem is in no way related to commerce and the catalog.

The problem is related to loading the display template control dynamicly. First time i load the control it takes relativly long time (and the app has been compiled and initialized at this time). But its off topic, so will investigate this further and perhaps take it up with EPiServer support.

#59524
Edited, Jun 14, 2012 12:57
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.