MvcOptimizations

Performance utilities for MVC5 applications


Keywords
Install
Install-Package MvcOptimizations -Version 1.0.9

Documentation

Author: Tore Lervik - http://mindre.net

Download: https://nuget.org/packages/MvcOptimizations or PM> Install-Package MvcOptimizations

Documentation

HtmlMinifierAttribute

Minifies the html-output to remove whitespace. Usually removes 15-20% of the content on MVC pages and only has about 1ms overhead. The filter will only trigger when the content type is text/html.

[HtmlMinifier]
public ActionResult Index() { ... }

// or

filters.Add(new HtmlMinifierAttribute());

CompressFilterAttribute

Used on JsonResult because Mvc doesn't gzip Json-output. Can also be used on other actions that doesn't compress by default.

[CompressFilter]
public JsonResult Articles() { ... }

Utilities.Cache

Helper method for easier object caching.

var articles = MvcOptimizations.Utilities.Cache("Articles", TimeSpan.FromMinutes(10), () =>
{
    var result = Service.GetArticles();
    SortArticles(result);
    return result;
});