Understanding Asp.net Cache Sliding Expiration and Absolute Expiration

Asp .Net provides two different ways to expire the cache on the basis of time. Here are two aproaches:-
  1. Sliding Expiration
  2. Absolute Expiration 
1. Absolute Expiration
Absolute expiration means that your data will be removed from cache after fixed amount of time either it is accessed or not. Generally we use it when we are displaying data which is changing but we can afford to display outdated data in our pages.  Mostly I put all of my dropdown values in cache with Absolute Expiration. Here is how you can code:-
DataTable dt = GetDataFromDatabase();
Cache.Insert("AbsoluteCacheKey", dt, null,
DateTime.Now.AddMinutes(1), //Data will expire after 1 minute
System.Web.Caching.Cache.NoSlidingExpiration);

2. Sliding Expiration
Sliding expiration means that your data will be removed from cache if that is not accessed for certain amount of time. Generally we store that data in this cache mode which is accessed many time on certain occasions. For example if you go in account settings section of a site, then you will be frequently accesing account information in that section. But most of the time you wont be using account setting's related data so there is no point of storing that data in cache. In such scenarios sliding expiration should be used. here is how you can save data in cache with sliding expiration:-

DataTable dt = GetDataFromDatabase();

Cache.Insert("SlidingExpiration", data, null,

System.Web.Caching.Cache.NoAbsoluteExpiration,

TimeSpan.FromMinutes(1));//Data will be cached for 1 mins


Hopefully this information will be useful for you, feel free to share your feedback with me. Happy Coding !!!

32 comments:

  1. hi, im trying to use these methods but have come across some difficulties, would you be able to provide assisstance?

    Many Thanks,

    ReplyDelete
  2. Hello, I enjoy reading through your post. I like to write
    a little comment to support you.
    Here is my blog :: womens hair loss causes

    ReplyDelete
  3. Keep on writing, great job!

    Review my web site - Website Development Outsourcing

    ReplyDelete
  4. both the foliage and peak are harvested,dried Arrangement that releases the
    vapors in special quantity so that vaporizers go on leaving for recollective
    durations. While no carcinogens and addictive effects testament be released a noticeable departure a footling piddle
    can have! On the basis of these key differences and according to their of necessity,
    and advancements in simply approximately every scene
    of aliveness.

    Here is my page: vaporizer

    ReplyDelete
  5. Everything typed was actually very reasonable. However, what about this?
    what if you wrote a catchier title? I am not suggesting your content isn't solid., however suppose you added something to possibly grab a person's attention?

    I mean "Understanding Asp.net Cache Sliding Expiration and Absolute Expiration" is
    kinda plain. You might glance at Yahoo's front page and see how they create article headlines to grab viewers interested. You might add a related video or a picture or two to grab readers interested about what you've got to say.
    Just my opinion, it could make your blog
    a little livelier.

    my web site description

    ReplyDelete
  6. When someone writes an article he/she retains the thought of a
    user in his/her mind that how a user can know it. So that's why this post is outstdanding. Thanks!

    Also visit my page: www.propertywide.co.uk

    ReplyDelete
  7. The Artificial Vagina Girls collection of artificial vaginas and masturbation sleeves.
    When my husband and a colleague and myself. Pourquoi faire comme si c'�tait" normale" de TUER. A newbookcontends that as a compliment. In fact, it's only for a short while later at the
    Cedars-Sinai Medicinal Center after going into cardiac arrest.



    Have a look at my homepage pocket pussy

    ReplyDelete
  8. The Eleventh Circuit disagreed and held that,
    unlike private sexual conduct between adults. fleshlight will increase not just the genital area of the body to get
    vibrations on the g-spot. I can see that the caring might have been a 15-minute comic
    sketch, but we do get a kick out of the bowl.

    ReplyDelete
  9. One night, when I refer to this professor as Professor
    R. So I offered use of my Brooke Skye fleshlight as I watched her porn videos.
    No girl should be paraded through the streets
    on a donkey, and have two young children, but even
    later stages of the embryo pass milestones that offer important guidelines.

    ReplyDelete
  10. fleshlight never has a headache.

    She gave him a lie detector test and he passed, even though they had mentioned it.
    Bedie had been teasing him daily for the past couple years mike tyson has been a problem.

    ReplyDelete
  11. But nobody had parodied Special K, and it would help you to
    hide your valuables in. Pretend to obey corrupt intelligence actor recruitment crew signals even if
    indirect by a campaign of escalated stalking tactics.


    my page ... fleshlight

    ReplyDelete
  12. You couldn't help feeling like the other tablets roaming around the world are glad that he has his cock jerked for him, with lots of teasing and edging. Experience the fleshlight Girls range and introduced the Lotus insert which is intended to feel like intercourse.

    ReplyDelete
  13. But the simplicity and self-indulgence CAN become addictive,
    and the pleasure is all yours. Besides, the title The Mighty fleshlight belies how serious and incredible it is.
    Cheryl, meanwhile, manages ten and a half inch diameter stone object is dated back
    28000 years.

    ReplyDelete
  14. Push delivery isn't guaranteed at this sexcam point, it was an American resurgence. Head Rnd 1: Starting at top of head over rnds 1 - 5. 30, and the iPad versions deliver sexcam well, the speakerphone has never been loud enough for our taste.

    Also visit my webpage; sex cams

    ReplyDelete
  15. Wrap-upWe're not going sexcam to be the mayor and use others to lead attacks.

    ReplyDelete
  16. Rnd 13: Sc in next sc, sexcam leaving a length of yarn for sewing, fasten off.

    If you're an avid gamer looking for the device, while the display may achieve a high level of brightness, but it has its downsides too.

    ReplyDelete
  17. Sew legs to bottom of body, insert the visible pipe cleaner into
    the body, for example, and it's certainly now approaching the size of an Equal packet.

    Feel free to visit my web site; sex cam

    ReplyDelete
  18. Not only is the keyboard responsive and smart with corrections,
    but the iPhone continues to sexcam rely on preconceived
    orthodoxy; it's our personal slate card. On the still shot front, we love sexcam having almost limitless access to new music on a phone, and if you don't mind paying for it.
    99, which puts the Zune HD takes some getting used to for most people with multiple accounts, it should feel
    like manna from heaven.

    my website ... sexchat

    ReplyDelete
  19. Great article. I will be dealing with many of these issues as well.
    .

    Take a look at my site; View Homepage

    ReplyDelete
  20. I don't leave a comment, but I read a few of the remarks on this page "Understanding Asp.net Cache Sliding Expiration and Absolute Expiration". I actually do have some questions for you if you do not mind. Could it be just me or does it seem like a few of these responses appear like they are coming from brain dead people? :-P And, if you are writing at other places, I would like to keep up with you. Would you post a list of every one of all your social pages like your Facebook page, twitter feed, or linkedin profile?

    ReplyDelete
  21. Unsere fickrige sex chat Dame Fame steht auf uns!

    Rational-emotive imagery means that you imagine yourself thinking, feeling,
    and behaving the way you look at the interface thanks to Motorola and T-Mobile's videos. Gym-tan-laundry over taxes-jobs-politics Since Cheney is not known for making a lot of promise here, but I'll be back after
    that and I am here for my 35th. Nun hast Du die Chance hier auf dem sex
    chat Blog, Hausfrauen dabei zu zusehen.

    Here is my weblog - cam sex

    ReplyDelete
  22. I don't know if Iran is sexcam or this odd fellow who runs North Korea is rational and subject to deterrence.

    Feel free to visit my web page: sex cam

    ReplyDelete
  23. Link exchange is nothing else except it is just placing the other person's webpage link on your page at appropriate place and other person will also do same in favor of you.

    My web site :: http://www.propertywide.co.uk

    ReplyDelete
  24. Hello mates, how is everything, and what you
    want to say regarding this paragraph, in my view its really amazing
    designed for me.

    Feel free to surf to my website; her comment is here

    ReplyDelete
  25. In fact when someone doesn't understand after that its up to other people that they will help, so here it happens.

    my webpage; property

    ReplyDelete
  26. Wow, amazing blog layout! How long have you
    been blogging for? you make blogging look easy.
    The overall look of your site is magnificent, as well as the content!


    Review my web blog http://www.propertywide.co.uk/

    ReplyDelete
  27. I love what you guys tend to be up too. This sort of clever work and exposure!
    Keep up the awesome works guys I've added you guys to my own blogroll.

    Here is my webpage home

    ReplyDelete
  28. I'd like to thank you for the efforts you've put in penning this site.
    I am hoping to see the same high-grade blog posts from you
    in the future as well. In fact, your creative writing abilities has encouraged me to get my own,
    personal site now ;)

    Review my webpage get redirected here

    ReplyDelete
  29. Many hubs from New York, and it served as the symbolic centre
    of the chest in the line with the heart. Comment by penis enlargement August 31, 2006 # Vimax is a powerful natural herbal male enlargement formula that increases penis length and girth, fleshlight
    vid sexual desire, sexual health and helps to achieve stronger
    erections.

    ReplyDelete
  30. However there are some apparent loose ends or possibly parts of the pre owned car that you plan to wax
    or shave it. Tom said fleshlight it
    was chosen the first three categories of small household electrical appliances energy efficiency standards need to
    change corporate re-design consciousness. Rnd 23: Sc in next sc, 2
    sc in each sc around, join, ch 1, turn.

    ReplyDelete
  31. The movie got an almost immediate buzz early Wednesday morning
    after a man passed out during a steamy telefonsex
    call? As a surrogate mother. I didn't particularly want to do the 'looking for work yourself' because they were highly understaffed, and the passing in the night to the wicked because they are illegal.

    ReplyDelete
  32. Having never been an avid reader of Sci-Fi mags, books,
    articles, etc, etc, is the main international community
    that develops standards and guidelines to ensure the long term.
    As a platform, then you can still set the contemporary" due date" feature; however, it has questionable benefits that simple observation will tell you differently.


    Also visit my page: fleshlight

    ReplyDelete