Umbraco: Set ContinouslyUpdateXmlDiskCache value programatically

I’m working on a site that requires the synchronisation of around 1000 content nodes to MYOB product data daily. In my quest to speed up the process I saw a post by Richard Soetman, developer of the excellent CMSImport package, where he advises to turn off the “ContinouslyUpdateXmlDiskCache” setting in umbracoSettings.config when performing bulk import operations.

I couldn’t find any code on how to do this, and being the .NET newbie that I am, it took me a little while to figure out. Here’s how I did it:

public static void SwitchContinuousUpdateOfXmlCacheState(bool newValue)
    if (UmbracoSettings.continouslyUpdateXmlDiskCache == newValue) return;

    var configFilePath = HttpContext.Current.Server.MapPath("~/config/umbracoSettings.config");

    if (File.Exists(configFilePath))
        var umbracoConfig = new XmlDocument();

        var key = umbracoConfig.SelectSingleNode("//ContinouslyUpdateXmlDiskCache");

        key.InnerText = newValue.ToString();


This way, I can toggle this setting off before performing the import, and then back on again after calling umbraco.library.RefreshContent();

I’m hoping this is the right approach. Feel free to let me know if it isn’t.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s