1

I have a ASP.NET MVC 3.0 project with a MySQL database that going to need caching on to get faster to load for users.

What is your best tip on how to do caching on a ASP.NET MVC project?

1
  • This is a very broad question. You don't even specify output caching or data caching. Better describe a typical page. Jul 7, 2011 at 6:30

2 Answers 2

4

If you want server-side caching (e.g caching "data"), you should look into .NET 4.0's new ObjectCache.

If you want output cache, you should decorate your action methods with said attribute, much like with Web Forms.

E.g:

[HttpGet]
[OutputCache(Duration = 60*5, VaryByParam("*")] // cache for 5 mins
public ActionResult GetSomethingThatDoesntChangeOften(int someParam, string someOtherParam)
{
   // some code  ...
}

You should use one or both, depending on the situation at hand.

E.g "weighty" database calls should be cached on the web server (e.g "data caching").

And HTML that doesn't change often should be cached on the client with output cache.

2
1

We use the Caching Application Block from Microsoft

http://msdn.microsoft.com/en-us/library/ff664753(v=pandp.50).aspx

1
  • agreed. That is way outdated. I mean the first line says "Retired Content".
    – RPM1984
    Jul 7, 2011 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.