Skip to content

Instantly share code, notes, and snippets.

@OzSimon
Last active February 6, 2019 07:03
Show Gist options
  • Save OzSimon/af468db0fe665fd526cafae30f7fa87e to your computer and use it in GitHub Desktop.
Save OzSimon/af468db0fe665fd526cafae30f7fa87e to your computer and use it in GitHub Desktop.
Asp.Net Core Startup Configure
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