Skip to content

Commit 6813b9d

Browse files
committed
feat(compression): enable compression sitewide
1 parent fba1c92 commit 6813b9d

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/StatCan.OrchardCore.Cms.Web/Startup.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using StatCan.OrchardCore.Security;
77
using Microsoft.Extensions.Configuration;
88
using Microsoft.AspNetCore.Http;
9+
using Microsoft.AspNetCore.ResponseCompression;
910

1011
namespace web
1112
{
@@ -29,7 +30,29 @@ public void ConfigureServices(IServiceCollection services)
2930
services.AddOrchardCms();
3031
services.Configure<IdentityOptions>(options =>
3132
{
32-
Configuration.GetSection("IdentityOptions").Bind(options);
33+
Configuration.GetSection("IdentityOptions").Bind(options);
34+
});
35+
services.Configure<GzipCompressionProviderOptions>(options => options.Level = System.IO.Compression.CompressionLevel.Optimal);
36+
services.AddResponseCompression(options =>
37+
{
38+
options.MimeTypes = new[]
39+
{
40+
// General
41+
"text/plain",
42+
// Static files
43+
"text/css",
44+
"application/javascript",
45+
// MVC
46+
"text/html",
47+
"application/xml",
48+
"text/xml",
49+
"application/json",
50+
"text/json",
51+
// WebAssembly
52+
"application/wasm",
53+
// Custom
54+
"image/svg+xml"
55+
};
3356
});
3457
}
3558

@@ -39,7 +62,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3962
{
4063
app.UseDeveloperExceptionPage();
4164
}
42-
65+
app.UseResponseCompression();
4366
app.UseStatCanSecurityHeaders()
4467
.UseStaticFiles()
4568
.UseOrchardCore(builder=>builder

0 commit comments

Comments
 (0)