forked from ddrilling/AsbCloudServer
Add compression
This commit is contained in:
parent
1061cee0cf
commit
917c79eaeb
@ -8,6 +8,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.ResponseCompression;
|
||||
|
||||
namespace AsbCloudWebApi
|
||||
{
|
||||
@ -96,7 +97,11 @@ namespace AsbCloudWebApi
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
services.AddResponseCompression(options =>
|
||||
{
|
||||
options.EnableForHttps = true;
|
||||
options.Providers.Add<GzipCompressionProvider>();
|
||||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
@ -115,23 +120,22 @@ namespace AsbCloudWebApi
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
//app.UseHttpsRedirection();
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles(
|
||||
//new StaticFileOptions
|
||||
//{
|
||||
// OnPrepareResponse = ctx =>
|
||||
// {
|
||||
// ctx.Context.Response.Headers.CacheControl = "public,max-age=2592000";
|
||||
// ctx.Context.Response.Headers.Expires = DateTime.UtcNow.AddDays(10).ToString("R", CultureInfo.InvariantCulture);
|
||||
// }
|
||||
//}
|
||||
new StaticFileOptions
|
||||
{
|
||||
OnPrepareResponse = ctx =>
|
||||
{
|
||||
ctx.Context.Response.Headers.CacheControl = "public,max-age=2592000";
|
||||
ctx.Context.Response.Headers.Expires = System.DateTime.UtcNow.AddDays(10).ToString("R", System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
);
|
||||
app.UseCors("ClientPermission");
|
||||
app.UseRouting();
|
||||
|
||||
app.UseResponseCaching();
|
||||
//app.UseResponseCompression();
|
||||
app.UseResponseCompression();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
Loading…
Reference in New Issue
Block a user