Questions tagged [httpcontext.cache]

27 questions
17
votes
3 answers

What is the most efficient way to store / retrieve items in asp.net httpContext.Cache

I have a website where I cache a lot of info. I am seeing conflicting information around storing stuff in the asp.net cache. For example lets say I have this data structure: Dictionary> mydictionary; I could store the whole…
leora
  • 188,729
  • 360
  • 878
  • 1,366
9
votes
1 answer

Schedule a task refreshing HttpContext.Cache every day at a certain time

I have an MVC 3 c# website running which pulls records from a webservice. As the dataset it gets from the webservice becomes bigger and bigger, I'm searching for a way that creating the cache of it isn't triggered by the first user to visit the site…
Daniël Tulp
  • 1,745
  • 2
  • 22
  • 51
7
votes
1 answer

What is the difference between HttpContext's Cache and Items Properties?

What is the difference between the HttpContext class's Cache and Items properties? From the MSDN Documentation: Cache Gets the Cache object for the current application domain. Items Gets a key/value collection that can be used to organize and…
Jesse Webb
  • 43,135
  • 27
  • 106
  • 143
6
votes
2 answers

How can I see what's in my HttpContext.Cache

Are there any good tools to see how much data (or even better the values of that data) is in my HttpContext.Cache?
kenwarner
  • 28,650
  • 28
  • 130
  • 173
6
votes
1 answer

how long, by default does stuff stay in httpcache if i don't put an explicit expiration?

i have the following code to cache some expensive code. private MyViewModel GetVM(Params myParams) { string cacheKey = myParams.runDate.ToString(); var cacheResults = HttpContext.Cache[cacheKey] as MyViewModel ; if…
leora
  • 188,729
  • 360
  • 878
  • 1,366
4
votes
4 answers

Application_End() cannot access cache through HttpContext.Current.Cache[key]

I want to be able to maintain certain objects between application restarts. To do that, I want to write specific cached items out to disk in Global.asax Application_End() function and re-load them back on Application_Start(). I currently have a…
Carl J.
  • 343
  • 1
  • 3
  • 8
3
votes
1 answer

HttpContext.Cache - Per Request or per App Domain?

Looking at the MSDN doc for .NET 2.0 of the HttpContext.Cache object it says this: The Cache for the current HTTP request. But looking at the .NET 3.0 version version it says: The Cache for the current application domain. That's a pretty…
Micah
  • 111,873
  • 86
  • 233
  • 325
3
votes
1 answer

HttpContext.Cache Physical Memory Usage

Is there any way to find the number of bytes of memory that are currently in the HttpContext.Cache? I've found where you can get the physical memory limit using EffectivePrivateBytesLimit or EffectivePercentagePhysicalMemoryLimit, but I'm having…
John Boker
  • 82,559
  • 17
  • 97
  • 130
3
votes
1 answer

Approaches to caching large number of objects (ASP.NET cache vs static objects & caching objects individually vs as dictionary)

I am writing a control that displays a list of items on the page. The database holds (lets say) 50,000 items which are related (many to many) with (lets say) 1000 pages. Instead of writing a stored procedure to return a set of complete items for a…
Laurence
  • 980
  • 12
  • 31
2
votes
1 answer

Why i have to put my object twice in HttpContext Cache before it keep it for good?

When i cache an object to the HttpContext Cache, my object disappear on the next read and I must reinsert the object a second time (not always but 90% of the time). After that, the object stay there without any problem. Here's what happen: Start…
Alexandre Jobin
  • 2,811
  • 4
  • 33
  • 43
2
votes
2 answers

System.Web.HttpContext.Current.Cache Different Results Returned In Different Browsers

I have a working ASP.Net web service that caches results using System.Web.HttpContext.Current.Cache (Insert and Get). For testing purposes, I show the time in the web service results. On the same browser, it properly caches and doesn't refresh…
John Cruz
  • 1,562
  • 4
  • 14
  • 32
2
votes
5 answers

Checking for null HttpContext.Current.Cache value

In the below snippet, I am trying to assign the cache value if the cache value does not already exist. I get an Object_reference_not_set_to_an_instance_of_an_object error when running the following. What am I missing? if…
yoyo
  • 79
  • 3
  • 11
2
votes
1 answer

How is HttpContext.Current.Cache saving objects in memory?

I am using HttpContext.Current.Cache to save objects into memory. The code i have looks something like this: public void Add(string key, object data, TimeSpan slidingExpirationTime) { HttpContext.Current.Cache.Insert(key, data, null,…
Catalin
  • 11,503
  • 19
  • 74
  • 147
2
votes
0 answers

Where is the actual location of items stored using HttpContext.Response.Cache?

I'm using HttpContext.Response.Cache to cache the responses from some of my HttpHandlers. My question should be simple but so far looking on Google I've not found a definite answer. I would like to know where the cached items are stored when using…
Daniel Hollinrake
  • 1,768
  • 2
  • 19
  • 39
1
vote
1 answer

Schedule HTTP Request in Asp.net site

Every night my HTTPContext.Current.Cache is cleared. I want to Warm up the site during the night at time X and fill the cache with data. Since I use HTTPContext, this has to run within the website. I am currently starting the caching by a simple…
JakobMiller
  • 323
  • 6
  • 19
1
2