Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Clear Cache of a product only



EPiServer Comere 8.6.1

I want a function that could Clear the cache (properties, idealy pricing also) of a product without effecting the rest of the site. Any Help

I am happy if it clear the local cache only in load balancing also.

My code will be something like 
ClearProductContentCache(strin product code){
//Clear Cache




Feb 04, 2015 16:48


Unfornately, I don't think it's a good idea to clear cache of a product only. The CatalogCache is used for CatalogEntryDto, but due to Dto nature, an Entry can be cached in multiple CatalogEntryDtos. We did some profiling and see that clean the entire CatalogCache can be faster than using RemoveByPattern to clear a specific cache correctly.

The good news is we are working on this to make the cache more efficient. Stay tuned :)



Feb 05, 2015 8:27

Thanks Quan, I need some help here.
Looooooong Story short, background of problem is that

In an Windows Sevice (Integration application) develoers are processing XML
and Save entries using CatalogSystem e.g. this.catalogSystem.SaveCatalogEntry(entryDto);

Those updated changes will not appear in Online Center Commerce section

Work arround written for that was after saving entry by catalog system they have written a service to notify change to website

That does following stuff


var productLink = referenceConvertor.GetContentLink(productCode, CatalogContentType.CatalogEntry);
var product = (ProductContent)contentLoader.Get<ProductContent>(productLink).CreateWritableClone();
var productSaveAction = product.LoadEntry().IsActive ? SaveAction.Publish: SaveAction.Reject;
contentRepository.Save(product, productSaveAction, AccessLevel.NoAccess);

They used CacheHelper.Clear(string.Empty) method that clears the whole site cache and if we got 1000s item in one feed it is clearing cache every time and in result it effect the live site very badly. In result as long as integration application is running site remains near about unresponsive.

Without  clearing cache it doesnot save/publish latest changes.

waiting for your advice/help on this. 


Feb 05, 2015 12:38

When you call this: 

contentRepository.Save(product, productSaveAction, AccessLevel.NoAccess);

CatalogCache should be cleared already. CacheHelper.Clear(string.Empty) will clear entire HttpContext.Current.Cache or HttpRuntime.Cache, so yes, it's very ineffficient. 

What is your "Online Center Commerce section"? You mean Catalog UI?

I think the better solution is to make sure your Windows Service to have proper event handling. I think your service is missing event configuration so it can't raise event to let the website knows there's change. If it's configured correctly then we do the synchronization just fine :)

Configurations can be found in <system.serviceModel> section of web.config.



Feb 05, 2015 13:06

Well, Correct me If I am wrong

If I Set up below settings in my Windows Service

then I wouln't need to publish as we are doing at this stage.



Feb 05, 2015 13:13

Yes, if the event system is working then after you saving an entry, it should appear in any where, both in Commerce Manager and in Catalog UI without additional steps.



Feb 05, 2015 13:16

I will give it a try, Thanks for your time.

Feb 05, 2015 13:18

I am using same settings in

Front Website
Commerce Manager Site
Windows Client

<add name="udpTransportCustom" type="Microsoft.ServiceModel.Samples.UdpTransportElement, EPiServer.Events" />
<service name="EPiServer.Events.Remote.EventReplication" behaviorConfiguration="DebugServiceBehaviour">
<!--<endpoint name="RemoteEventServiceEndPoint" contract="EPiServer.Events.ServiceModel.IEventReplication" bindingConfiguration="RemoteEventsBinding" address="net.tcp://localhost:13000/RemoteEventService" binding="netTcpBinding"/>-->
<endpoint name="RemoteEventServiceEndPoint" contract="EPiServer.Events.ServiceModel.IEventReplication" binding="customBinding" bindingConfiguration="RemoteEventsBinding" address="soap.udp://" />
<!-- Uncomment this endpoint and the "RemoteEventServiceEndPoint" to enable remote events -->
<endpoint name="RemoteEventServiceClientEndPoint" address="soap.udp://" binding="customBinding" bindingConfiguration="RemoteEventsBinding" contract="EPiServer.Events.ServiceModel.IEventReplication" />
<behavior name="DebugServiceBehaviour">
<serviceDebug includeExceptionDetailInFaults="true" />
<behavior name="EPiServer.Business.Commerce.EventServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<behavior name="CommerceSiteBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<behavior name="EventServiceEndpointBehavior">
<webHttp />
<binding name="RemoteEventsBinding">
<binaryMessageEncoding />
<udpTransportCustom multicast="True" />

With changes in windows client, I can see the updates in Commerce Manager through catlog Management
Press F5, changes are not visible in Online center Catalog UI.
If I Save that product from Commerce Manager, Changes are visible in Catalog UI 

Didn't worked. Any idea?

Feb 05, 2015 17:09

It looks like your service is also missing the configuration for Framework, it should have something like this:

<scanAssembly forceBinFolderScan="true" />
<appData basePath="appData" />

This allows Framework to scan the assembly and register types related to event system.



Feb 06, 2015 2:49

Didn't work. can I forward you app.config on your email (i have your email address). 


Feb 06, 2015 9:28

Sure :)

I will try to take a look when I have time. But if I can't resolve it in a reasonable timeframe you will need to contact our developer support service.



Feb 06, 2015 13:26

for updates...
I couldn't  manage catalog events yet but mean while i found this interesting thing


It is clearing cache for a particular product/variant, I am wondering in there any catalyst you are aware of if i use this function.


Feb 19, 2015 16:55

If you enable debug output for EPiServer.Events in the site, can you see that it is actually receiving the cache invalidation event? Also, I am not really familiar with UDP-configured remote events, but as for TCP the config shouldn't be the same in all sites. Depending on who's broadcasting and who's listening the configs differ.

Feb 19, 2015 18:42

(UDP)Receiving is OK but Broadcasting from Integration application is an issue. 

Feb 23, 2015 14:05

With commerce 8.9 you have new possibilities to work with cache dependencies for this:

Mar 10, 2015 10:47
* 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.