how to stop purging of Application cache?

Discussion in 'ASP.NET / ASP.NET Core' started by jmagaram, Jun 26, 2008.

  1. I am putting stuff in the application cache like this...

    Application["customerEmail"]=...

    It gets purged quickly. Customer support said the reasons for purging are...


    1. The application has exceeded 200 MB of memory.
    2. The application is utilizing 75% CPU resources for over 5 minutes.
    3. Your application is idle for over 20 minutes.

    Only 3 is possible in my case. How do I stop the cache from emptying after 20 minutes? What can I do?
     
  2. If I'm not mistaken, it looks like you're storing your customer info in the Application cache?If so, then this the wrong way to go about it, since application variables are globally shared. I recommend storing it in a database with either your own schema or use SQL session.

    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. can other discountasp.net customer's see it? if not, what is wrong with my approach? here's what i'm really using it for. i store my customer service phone number there when i'm available to answer the call. ifi leave the house i change the # to my cell phone. when i go to sleep i set it to the null string. my web site displays the phone number if it exists in the cache. it's an experiment i'm doing with my web site to see if showing a phone number increases conversions. seems like the cache should be able to hold on to it for more than 20 minutes. there also is a "Cache" variable in my web pages that provides more control over timeout, sliding expiration, etc. i wonder if it would last more than 20 minutes there.
     
  4. There's no way to change the 20 minute expiration within your app, and I don't think DASP is going to change it for the server, so you have a few other options you can use:

    1. Use some sort of "keep alive" service to continually hit your app every 15 minutes to keep it from shutting down. You can just point a browser page with a meta refresh at it, or if you don't have a machine that stays on all the time there are services out there you can pay to have do it.
    2. Store the number in your database, or if you don't have a database store it on disk.

    A disk-based cache should be pretty quick if you're just storing a phone number. Also, if you know how the configuration system in .NET works, you can alternatively just put it in an AppSettings variable and save the new one when needed.

    Hope that helps.
     
  5. You shouldn't put anything into application cache that you're not prepared to lose and have to re-fetch somehow.

    Setting up a scheduled task or some service to "ping" your site every15-20 minutes would prevent your site from recycling due to inactivity, but not for other reasons, so it's not a fool proof solution. Storing the value in a database or even just a text or config file would be the most appropriate in this case.

    As that approach is technically slower, if you needed quick responsiveness you could still store it in the Application cache, and keep your existing code that sets the application variable... add a global.asax file. On the Application_Start() event, retrieve the email from the database/disk and store it in Application["customerEmail"]. On Application_End(), save whatever the value of Application["customerEmail"] is to database/disk. This way your app can recycle at any given time and you'll still always have your value in the app cache.
     

Share This Page