I just hooked up the mvc-mini-profiler (thanks SO!) on my site and was looking around to see how well I've done up to this point (it's my first major bout with linq to entities and mvc). So far everything is looking good, however I'm always looking for ways to improve response times. At this point it looks like the only major boost I could get would be from reducing the time it takes to render the individual views on each of my pages.
You can see from my screeny that the rendering of the Blog
view is the longest running task. I know that 30ms is already really quick, but I'm betting there are still some tricks I can pull to get these numbers even lower.
So the question is this: How can I reduce view render times? I know that caching of dynamic views into something like the HttpRuntime.Cache
can help, but I'm even seeing several ms durations for static view rendering. What techniques do you use to lower the render times of your views?
Faster development process:MVC supports rapid and parallel development. If an MVC model is used to develop any particular web application then it is possible that one programmer can work on the view while the other can work on the controller to create the business logic of the web application.
I suggest 2 things (if you don't have it done yet)...
Remove unused ViewEngines. So if your project uses only the razor view engine, do this in the global.asax on Application_Start();
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
or
ViewEngines.Engines.Add(new WebFormViewEngine());
if you use the WebFormsViewEngine only
The biggest improvment is to use the OutputCacheAttribute to cache the html. I dont think your Blog changes on every Request ;)
public class BlogController : Controller
{
[OutputCache]
public ActionResult Index()
{
// do something here
return View();
}
}
You can set the cache-duration and more. Check out: MSDN - OutputCacheAttribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With