Skip to content

Instantly share code, notes, and snippets.

@DDzia
Last active January 29, 2019 20:47
Show Gist options
  • Save DDzia/ab69a816b7dc7a81b15a75cfd30e5801 to your computer and use it in GitHub Desktop.
Save DDzia/ab69a816b7dc7a81b15a75cfd30e5801 to your computer and use it in GitHub Desktop.
using System;
using System.Diagnostics;
using System.Linq;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(WebApplication5.Startup))]
namespace WebApplication5
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Use((ctx, next) =>
{
// enable cache-control injection if caching strategy has not been setted manually
if (!ctx.Response.Headers.Keys.Any(x => x.Equals("Cache-Control", StringComparison.InvariantCultureIgnoreCase)))
{
ctx.Response.Headers.Add("Cache-Control", new []{"no-cache, no-store, must-revalidate"});
Debug.WriteLine("The Cache-Control was been added.");
}
Debug.WriteLine("The Cache-Control header is exists.");
return next();
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment