Asp.net core 学习笔记 ( IIS, static file 性能优化 )
2017-11-06 12:58
1731 查看
refer :
https://weblog.west-wind.com/posts/2017/Apr/27/IIS-and-ASPNET-Core-Rewrite-Rules-for-AspNetCoreModule https://docs.microsoft.com/en-us/aspnet/core/performance/response-compression?tabs=aspnetcore2x https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files https://andrewlock.net/html-minification-using-webmarkupmin-in-asp-net-core/ https://github.com/Taritsyn/WebMarkupMin
core host in IIS 会拦截所有的请求, 包括静态文件
可是 IIS 处理静态文件压缩等等还是不错的
那我们可以在 webconfig 里去设置一下
做一个 rewrite 还有 handlers 就可以了.
如果要处理 html minify 可以使用这个 plugin WebMarkupMin
https://weblog.west-wind.com/posts/2017/Apr/27/IIS-and-ASPNET-Core-Rewrite-Rules-for-AspNetCoreModule https://docs.microsoft.com/en-us/aspnet/core/performance/response-compression?tabs=aspnetcore2x https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files https://andrewlock.net/html-minification-using-webmarkupmin-in-asp-net-core/ https://github.com/Taritsyn/WebMarkupMin
core host in IIS 会拦截所有的请求, 包括静态文件
可是 IIS 处理静态文件压缩等等还是不错的
那我们可以在 webconfig 里去设置一下
<configuration> <system.webServer> <rewrite> <rules> <rule name="wwwroot-static"> <match url="([\S]+[.](html|htm|svg|js|css|png|gif|jpg|jpeg|json|mp3|mp4|woff|woff2))" /> <action type="Rewrite" url="wwwroot/{R:1}" /> </rule> </rules> </rewrite> <handlers> <add name="StaticFileModuleSvg" path="*.svg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleJs" path="*.js" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleCss" path="*.css" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleJpeg" path="*.jpeg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleJpg" path="*.jpg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModulePng" path="*.png" verb ="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleGif" path="*.gif" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleJson" path="*.json" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleMp4" path="*.mp4" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleMp3" path="*.mp3" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleWoff" path="*.woff" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFileModuleWoff2" path="*.woff2" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore processPath=".\Project.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /> <staticContent> <remove fileExtension=".woff" /> <mimeMap fileExtension=".woff" mimeType="application/font-woff" /> <remove fileExtension=".json" /> <mimeMap fileExtension=".json" mimeType="application/json" /> <remove fileExtension=".mp4" /> <mimeMap fileExtension=".mp4" mimeType="audio/mp4" /> <remove fileExtension=".ogg" /> <mimeMap fileExtension=".ogg" mimeType="audio/ogg" /> <!--local iis no allow below--> <remove fileExtension=".less"/> <mimeMap fileExtension=".less" mimeType="text/css" /> <remove fileExtension=".woff2"/> <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" /> <clientCache cacheControlMode="UseExpires" httpExpires="Tue, 12 Jan 2027 03:14:07 GMT" /> </staticContent> <defaultDocument> <files> <clear /> <add value="index.aspx" /> <add value="Default.aspx" /> <add value="index.html" /> <add value="Default.html" /> </files> </defaultDocument> </system.webServer> </configuration>
做一个 rewrite 还有 handlers 就可以了.
如果要处理 html minify 可以使用这个 plugin WebMarkupMin
相关文章推荐
- [学习笔记] ASP.NET应用程序性能优化
- 黑马程序员之ASP.NET学习笔记: 几个常用方法有效优化ASP.NET的性能
- Asp.net core 学习笔记 ( Router 路由 )
- 学习ASP.NET MVC5框架揭秘笔记-IIS/ASP.NET管道(一)
- ASP.NET Core 2.0系列学习笔记-NLog日志配置文件
- ASP.NET Core 2 学习笔记(九)模型绑定
- ASP.NET Core 2 学习笔记(十)视图
- ASP.NET Core 2.0系列学习笔记-ADO.NET-MSSQLServerHelper
- 笔记:Asp.Net应用程序性能优化
- Asp.net core 学习笔记 ( HttpClient )
- [译]【NetCore学习笔记之Anchor TagHelper】ASP.NET Core MVC Anchor Tag Helper
- Asp.net core 2.0.1 Razor 的使用学习笔记(四)
- asp.net core学习笔记-1
- .net学习笔记---IIS 处理模型及ASP.NET页面生命周期
- 学习笔记---将Asp.Net网站发布到IIS的四种方法及注意事项
- ASP.NET Core 2 学习笔记(一)开始
- ASP.NET Core 2 学习笔记(八)URL重写
- (10)学习笔记 ) ASP.NET CORE微服务 Micro-Service ---- Ocelot+Identity Server
- ASP.NET Core 2.0系列学习笔记-启动类Startup
- (9)学习笔记 ) ASP.NET CORE微服务 Micro-Service ---- JWT算法