Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:31:01+00:00 2026-06-02T02:31:01+00:00

I want to clear Sitecore cache for an item programmatically. I ran the code

  • 0

I want to clear Sitecore cache for an item programmatically. I ran the code below. After that I tried to do a web.GetItem() on the deleted id and I still get a null. Any suggestions?

Database db = new Database("web");

if (ID.IsID(id))
{
    ID itemID = new ID(id);
    
    //clear data cache
    db.Caches.DataCache.RemoveItemInformation(itemID);
    
    //clear item cache
    db.Caches.ItemCache.RemoveItem(itemID);
    
    //clear standard values cache
    db.Caches.StandardValuesCache.RemoveKeysContaining(itemID.ToString());

    //remove path cache
    db.Caches.PathCache.RemoveKeysContaining(itemID.ToString());
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:31:02+00:00Added an answer on June 2, 2026 at 2:31 am

    Looks like you have missed the prefetch cache, here is how to get it:

    private Cache GetPrefetchCache(Database database)
    {
        foreach (var cache in global::Sitecore.Caching.CacheManager.GetAllCaches())
        {
            if (cache.Name.Contains(string.Format("Prefetch data({0})", database.Name)))
            {
                return cache;
            }
        }
    }
    

    And the html cache also:

    private void ClearAllHtmlCaches() 
    {
        foreach (var info in Factory.GetSiteInfoList())
        {
            info.HtmlCache.Clear();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have a Sticky form that after successful completion I want to clear
i want to clear the fields of my form after the user has inserted
I want to clear dataview item when it lost focus, mean when user click
I want to clear textbox after ajax posting. <div style=padding: 5px; background-color: Silver;> @using
I want to clear textbox after ajax posting. <div style=padding: 5px; background-color: Silver;> @using
All I want is to clear my renderTarget2D once so that it starts off
I want to clear the java script based on few conditions that is related
I want to clear the screen (on the local machine) after exiting from my
I want to clear all forms on page load. I tried to use this
Using classic ASP I want to clear a form that auto populates with session

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.