From 28e6c347486ab25cc563e753b2ad22966c82fd96 Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Sat, 27 Jan 2018 22:25:30 -0800 Subject: [PATCH] Removed unecessary headers. Added cache headers for favicon and logo --- Teknik/Controllers/DefaultController.cs | 16 ++++++++++------ Teknik/Global.asax.cs | 8 ++++++++ Teknik/Web.config | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Teknik/Controllers/DefaultController.cs b/Teknik/Controllers/DefaultController.cs index a620d53..245b261 100644 --- a/Teknik/Controllers/DefaultController.cs +++ b/Teknik/Controllers/DefaultController.cs @@ -75,26 +75,30 @@ namespace Teknik.Controllers // Get the Favicon [HttpGet] [AllowAnonymous] - [OutputCache( - Duration = 31536000, - Location = OutputCacheLocation.ServerAndClient)] public ActionResult Favicon() { // Get favicon string imageFile = Server.MapPath(Constants.FAVICON_PATH); + + Response.Cache.SetCacheability(HttpCacheability.Public); + Response.Cache.SetMaxAge(new TimeSpan(365, 0, 0, 0)); + Response.Cache.SetLastModified(System.IO.File.GetLastWriteTime(imageFile)); + return File(imageFile, "image/x-icon"); } // Get the Logo [HttpGet] [AllowAnonymous] - [OutputCache( - Duration = 31536000, - Location = OutputCacheLocation.ServerAndClient)] public ActionResult Logo() { // Get favicon string imageFile = Server.MapPath(Constants.LOGO_PATH); + + Response.Cache.SetCacheability(HttpCacheability.Public); + Response.Cache.SetMaxAge(new TimeSpan(365, 0, 0, 0)); + Response.Cache.SetLastModified(System.IO.File.GetLastWriteTime(imageFile)); + return File(imageFile, "image/svg+xml"); } diff --git a/Teknik/Global.asax.cs b/Teknik/Global.asax.cs index 4f166a2..55e8d5b 100644 --- a/Teknik/Global.asax.cs +++ b/Teknik/Global.asax.cs @@ -32,6 +32,8 @@ namespace Teknik AntiForgeryConfig.RequireSsl = true; + MvcHandler.DisableMvcResponseHeader = true; + FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); @@ -45,6 +47,12 @@ namespace Teknik stopwatch.Start(); } + protected void Application_PreSendRequestHeaders(object sender, EventArgs e) + { + // Remove stupid headers + HttpContext.Current.Response.Headers.Remove("Server"); + } + protected void Application_EndRequest(object sender, EventArgs e) { try diff --git a/Teknik/Web.config b/Teknik/Web.config index 7692517..e782add 100644 --- a/Teknik/Web.config +++ b/Teknik/Web.config @@ -47,7 +47,7 @@ - +