3

In SharePoint we can clear the object cache from Site Collection Administration - Site collection object cache

Is there a way to do the same programmatically?

1

I know Serge van den Oever have found a way to do this (in SP2007), but since some of the classes and methods you need to call are internal, you need to use reflection to get it working.

http://weblogs.asp.net/soever/archive/2009/06/19/sharepoint-wcm-flushing-publishing-pages-from-the-cache.aspx

NB: The publishing framework have been reworked alot in SP2010, so it might have changed alot.

A quick look in the API only gave this: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.publishingcache.flushblobcache.aspx

So its likely that this is still internal methods

1

There was one suggestion posted to stackoverflow forum https://stackoverflow.com/questions/3046576/how-to-flush-object-cache-in-sharepoint-programmatically

C#:

SiteCacheSettingsWriter writer=new SiteCacheSettingsWriter(site);
writer.SetFarmCacheFlushFlag();
writer.Update();

PowerShell:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing.dll")
$site = Get-SPSite https://....
$writer = new-object "Microsoft.SharePoint.Publishing.SiteCacheSettingsWriter" $site
$writer.SetFarmCacheFlushFlag()
$writer.Update()
  • From SO help: Provide context for links Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. – Janis Veinbergs Dec 20 '18 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy