i want to use output caching to avoid hitting my db over and over with the same static query but my controllers have parameters that uniquely define the post.
How can i factor in my parameters and still support output caching in asp.net-mvc?
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.
Check out the VaryByParam property of the OutputCache attribute.
For each unique id value, a unique cache instance will be created.
Edit:
If your caching needs go beyond simple VaryByParam scenarios then take a look at VaryByCustom. This will allow you to setup the scenarios as you see fit (cached version for logged in vs. not logged in user, etc. etc.)