diff --git a/src/Mix.Cms.Web/Startup.cs b/src/Mix.Cms.Web/Startup.cs index ad57d82e8..0a36ac329 100644 --- a/src/Mix.Cms.Web/Startup.cs +++ b/src/Mix.Cms.Web/Startup.cs @@ -24,6 +24,7 @@ using Mix.Services; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.Linq; using System.Text.Unicode; @@ -62,7 +63,7 @@ public void ConfigureServices(IServiceCollection services) }); services.AddResponseCompression(); - + services.AddResponseCaching(); services.AddControllersWithViews() .AddRazorRuntimeCompilation() .AddNewtonsoftJson(options => @@ -136,9 +137,27 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) } app.UseResponseCompression(); + app.UseCors(MixcoreAllowSpecificOrigins); + app.UseResponseCaching(); + app.Use(async (context, next) => + { + context.Response.GetTypedHeaders().CacheControl = + new Microsoft.Net.Http.Headers.CacheControlHeaderValue() + { + Public = true, + MaxAge = TimeSpan.FromSeconds(100), + NoStore = false, + + }; + context.Response.Headers[Microsoft.Net.Http.Headers.HeaderNames.Vary] = + new string[] { "accept-encoding" }; + + await next(); + }); + var provider = new FileExtensionContentTypeProvider(); // Add new mappings app.UseDefaultFiles();