Last active
January 29, 2019 20:47
-
-
Save DDzia/ab69a816b7dc7a81b15a75cfd30e5801 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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