8000 Add response caching by nhathoang989 · Pull Request #532 · mixcore/mix.core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ mix.core Public template

Add response caching #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
21 changes: 20 additions & 1 deletion src/Mix.Cms.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,7 +63,7 @@ public void ConfigureServices(IServiceCollection services)
});

services.AddResponseCompression();

services.AddResponseCaching();
services.AddControllersWithViews()
.AddRazorRuntimeCompilation()
.AddNewtonsoftJson(options =>
Expand Down Expand Up @@ -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();
Expand Down
0