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 8153473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:01:37+00:00 2026-06-06T16:01:37+00:00

I have a really strange problem and I’m completely puzzled. I have a piece

  • 0

I have a really strange problem and I’m completely puzzled.

I have a piece of code that parses some data and stores the result in our webserver’s HttpRuntime.Cache using the Insert method. This is stored for 10 seconds. There seem to be some problems so I created a test page that retrieves a simple object from the cache and displays if it is null or not. To add the object to the cache, I use:

HttpRuntime.Cache.Insert(CHECK_KEY, new object(), null, DateTime.Now.AddSeconds(10), System.Web.Caching.Cache.NoSlidingExpiration);

In a test page, I try to retrieve the object:

var isInCache = this.cacheService.Get<object>(CHECK_KEY) != null;

and the method of the cacheService is:

public T Get<T>(string key)
{
  return (T)HttpRuntime.Cache.Get(key);
}

Now the strange part. If I call a URL that calls the ‘Insert’ method, and go to my test page to retrieve it, the value of isInCache is false in about 99% of the time. Sometimes it works correctly for the whole 10 seconds (e.g. I refresh my test page every second and I get true 10 times) but again, most of the time it just returns false.
Now, when I keep F5 pressed, I sometimes see true in my output, in the blink of an eye, which means that the key CAN be found! This is not some browser cache, because it will only flash true intermittetly for the 10 seconds of cache duration, after which is it will only display false (which is logical, since the key is expired). So my question is:

  • WHY will retrieving a simple object from the cache fail most of the time?
  • There are other items in the cache (on the same test page) that do get retrieved, just not that object.

To make things worse, this (of course!) works flawlessly on my local machine, on the test machine, just not production. I’m pretty clueless. Please help 🙂

EDIT:
Ok so I’m now testing in two different browsers, IE9 and Chrome… and IE9 is correctly showing the items in the HttpRuntime.Cache but Chrome is NOT. It shows always false and no other cached data, except when keeping F5 pressed it will occassionally show it. Since when is HttpRuntime.Cache browser dependant???
Extra edit: IE9 shows no more cached data. So while it can differ across browsers, it’s not that IE will always work and chrome not… it differs.

EDIT2:
So I’m passing the variables to my view using ViewData:

ViewData["machineName"] = machineName;
ViewData["isInCache"] = isInCache;
ViewData["A"] = A;
ViewData["B"] = B;

Machinename comes from Server.MachineName, isInCache is the object, variable A is not from the HttpRuntime.Cache, variable B does, which is also intermittently not present.

  • 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-06T16:01:39+00:00Added an answer on June 6, 2026 at 4:01 pm

    After much debugging and thought, it appeared that the hosting provider had the ‘Maximum Worker Processes’ in IIS 7 Application pool settings to a value larger than 1. The HttpRuntime.Cache is not shared in a web farm, thus it could well be that I hit the ‘wrong’ instance which did not have the object cached. Continuously pressing F5 would have me occassionaly hit the instance which did have the value cached.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive got a really strange problem with some javascript code that ive written. I
I'm having a really strange problem. Here is the code I have that should
I have a strange problem in my code that I really can't explain and
I am having some strange problem and its really frustating me. I have a
So this is a really strange problem. I have a Java app that acts
I have a really strange problem that I can't explain and fix, it is
I'm facing a really strange problem that has me smoked. I have a fairly
I've got a strange problem here. Assume that I have a class with some
I have a really strange problem with this code: In this Fiddle it alert's
I have a really strange problem. My example code works [here][1] quite fine, but

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.