Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • suman 30 posts 101 karma points
    Aug 14, 2018 @ 11:10
    suman
    0

    Umbraco Cache Problem (Server CPU Utilisation going to 100%)

    For clearing cache, we have used the below two lines of code...

    • HttpContext.Current.Cache.Remove("somestring");
    • HttpRuntime.Close();

    When we call the clear-cache page, My server CPU utilization is going to 100% and automatically website is getting down.

    Can anyone help me what is the wrong in my code, please?

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Aug 14, 2018 @ 11:41
    Dave Woestenborghs
    0

    Hi Suman,

    I think this is pretty normal. When calling HttpRuntime.Close(); you actually tell your web application to shutdown.

    See : https://docs.microsoft.com/en-us/dotnet/api/system.web.httpruntime.close?view=netframework-4.7.1#SystemWebHttpRuntime_Close

    Why are you calling this ?

    Dave

  • suman 30 posts 101 karma points
    Aug 14, 2018 @ 12:20
    suman
    0

    Hi Dave, Thank you for your reply.

    I thought it will clear the cache for the current request.

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Aug 14, 2018 @ 12:21
    Dave Woestenborghs
    0

    I think removing this one will solve your issue.

    Dave

  • suman 30 posts 101 karma points
    Aug 14, 2018 @ 12:23
    suman
    0

    Thank You Dave. I will try this and monitor the CPU Utilization.

  • Greg Hluska 25 posts 133 karma points
    Aug 14, 2018 @ 11:46
    Greg Hluska
    0

    Is that the only code on the entire clear cache page? If not, would you post more?

  • suman 30 posts 101 karma points
    Aug 14, 2018 @ 12:17
    suman
    0

    @Greg,

    full code for clear cache...

    @ string prefix = null; if (prefix == null) { prefix = ""; } prefix = prefix.ToLower(); List

    System.Collections.IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();
    while (enumerator.MoveNext())
    {
        if (enumerator.Key.ToString().ToLower().StartsWith(prefix))
        {
            itemsToRemove.Add(enumerator.Key.ToString());
        }
    }
    
    foreach (string itemToRemove in itemsToRemove)
    {
        HttpContext.Current.Cache.Remove(itemToRemove);
    }
    
     HttpContext.Current.Cache.Remove("somestring");
     HttpRuntime.Close();
    

    }

Please Sign in or register to post replies

Write your reply to:

Draft