I’m using OutputCache to avoid execute same code everytime, but I have the following problem:
when it expires, a random user have to pay the cost to execute this code. Can avoid it??
I’m using asp.net MVC 4.0.
thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
If data is really immutable, you can set Duration property to max value and forget.
But if cache entry expires, you have to load fresh data anyway. By design, OutputCacheAttribute allows to load data on demand only. If you want to precache data, you should invent your own caching mechanism, or extend OutputCacheAttribute someway.