开发者

Why my httpcontext.cache works in localhost but not production?

I am using HttpContext.Cache to cache my data but it only works in my localhost.

In production, the cache doesn't works, my method always go to my database retrive the data, instead catch them from the cache. I use just one instance of Sql Server and one web server.

My code is like this

 protected void LoadMenuSistem()
        {
            string menu = ""; 
            if (Cache["menuSistem"] != null)
            {
                Response.Write(Cache["menuSistem"].ToString());
            }
            else
            {
                  // Retrive data from  database and开发者_StackOverflow社区 populate the string menu
            }

            Cache["menuSistem"] = menu;
}


please check the CPU Usage and RAM size in your production server. incase of low memory in the server cached items to be removed to free memory based on the priority set. This process is known as scavenging.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜