Last active
February 6, 2019 07:03
-
-
Save OzSimon/af468db0fe665fd526cafae30f7fa87e to your computer and use it in GitHub Desktop.
Asp.Net Core Startup Configure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { | |
if (env.IsDevelopment()) { | |
app.UseDeveloperExceptionPage(); | |
} | |
else { | |
app.UseExceptionHandler("/Error"); | |
app.UseHsts(); | |
} | |
app.UseHttpsRedirection(); | |
app.UseResponseCaching(); | |
app.UseResponseCompression(); | |
app.UseStaticFiles(new StaticFileOptions { | |
OnPrepareResponse = x => { | |
int duration = env.IsDevelopment() ? 300 : 604800; | |
x.Context.Response.Headers.Append("Cache-Control", $"public, max-age={duration}"); | |
} | |
}); | |
app.UseHTMLMinification(); | |
app.UseMvc(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment