Author: Tore Lervik - http://mindre.net
Download: https://nuget.org/packages/MvcOptimizations or PM> Install-Package MvcOptimizations
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());
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() { ... }
Helper method for easier object caching.
var articles = MvcOptimizations.Utilities.Cache("Articles", TimeSpan.FromMinutes(10), () =>
{
var result = Service.GetArticles();
SortArticles(result);
return result;
});