ASP.NET(支持 ASP.NET MVC)性能优化包 - combres 介绍

时间:2023-07-20 08:06:13

项目地址:https://github.com/buunguyen/combres

Overview

Combres (previously hosted in CodePlex) helps your ASP.NET and ASP.NET MVC applications perform faster and rank better with YSlow and PageSpeed.

Features highlights:

  • All in one solution supporting JS/CSS combinationminificationcompression and caching (by adding properExpires/Cache-Control headers, ETag and server-side caching)
  • Easy to use, simply download it via Nuget, declare JS and CSS resource groups in an XML file and use them in your pages, Combres will take care of the rest
  • Integrated with ASP.NET routing engine and work with ASP.NET WebForm 3.5/4.0/4.5, ASP.NET MVC 2/3/4 and Azure web applications
  • Detect changes in Combres config file, managed JS/CSS files and support auto-versioning, so you don't have to manually rebundle JS/CSS resources after making changes to them
  • Extensible architecture with many extension points
  • And many more: CDN, HTTPS, debug mode, external JS/CSS (dynamically requested from other servers), Less CSS etc.
  • Proven solution with many thousands of downloads in NuGetCodePlex and The Code Project

Check out this Code Project article for a thorough introduction.

Usage

Install from NuGet

PM> Install-Package combres
PM> Install-Package combres.log4net (optional)
PM> Install-Package combres.mvc (optional)

Optional steps for ASP.NET 3.5 users, those using ASP.NET 4 or above can ignore:

  • Delete the generated file AppStart_Combres.cs
  • Open global.asax code-behind file:
    • Import Combres namespace
    • Add this line to the first line of either RegisterRoutes() or Application_Start():RouteTable.Routes.AddCombresRoute("Combres")

Edit App_Data/Combres.xml to declare your JS and CSS resources

Use resource groups in your pages as follows:

<%= WebExtensions.CombresLink("siteCss") %>
<%= WebExtensions.CombresLink("siteJs") %>

ASP.NET MVC developers can import Combres.Mvc namespace and declare CSS/JS like below:

@using Combres.Mvc;
...
@Url.CombresLink("siteCss")
@Url.CombresLink("siteJs")

That should be it. Start your browser to observe Combres in action. For more advanced usages, refer to these resources:

谢谢浏览!