😎增加压缩响应
This commit is contained in:
parent
842b236250
commit
8d7e7ce61b
@ -18,12 +18,14 @@ using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.ResponseCompression;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
using OnceMi.AspNetCore.OSS;
|
||||
using SixLabors.ImageSharp.Web.DependencyInjection;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Admin.NET.Web.Core;
|
||||
@ -207,10 +209,37 @@ public class Startup : AppStartup
|
||||
// 设置默认查询器China和International
|
||||
//IpToolSettings.DefalutSearcherType = IpSearcherType.China;
|
||||
IpToolSettings.DefalutSearcherType = IpSearcherType.International;
|
||||
|
||||
// 配置gzip与br的压缩等级为最优
|
||||
//services.Configure<BrotliCompressionProviderOptions>(options =>
|
||||
//{
|
||||
// options.Level = CompressionLevel.Optimal;
|
||||
//});
|
||||
//services.Configure<GzipCompressionProviderOptions>(options =>
|
||||
//{
|
||||
// options.Level = CompressionLevel.Optimal;
|
||||
//});
|
||||
// 注册压缩响应
|
||||
services.AddResponseCompression((options) =>
|
||||
{
|
||||
options.EnableForHttps = true;
|
||||
options.Providers.Add<BrotliCompressionProvider>();
|
||||
options.Providers.Add<GzipCompressionProvider>();
|
||||
options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
|
||||
{
|
||||
"text/html; charset=utf-8",
|
||||
"application/xhtml+xml",
|
||||
"application/atom+xml",
|
||||
"image/svg+xml"
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
// 响应压缩
|
||||
app.UseResponseCompression();
|
||||
|
||||
app.UseForwardedHeaders();
|
||||
|
||||
if (env.IsDevelopment())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user