From 684bd4f96930d1abd24e26cb9e1b54951b44adfd Mon Sep 17 00:00:00 2001 From: Thomas Hounsell Date: Tue, 13 Oct 2015 21:01:47 +0100 Subject: [PATCH] Output caching temporarily disabled Will need to fix so that it varies by language. --- BuildFeed/Controllers/frontController.cs | 26 +++++------ BuildFeed/Controllers/supportController.cs | 6 +-- BuildFeed/Global.asax.cs | 52 +++++++++++----------- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/BuildFeed/Controllers/frontController.cs b/BuildFeed/Controllers/frontController.cs index feeb628..f7a95de 100644 --- a/BuildFeed/Controllers/frontController.cs +++ b/BuildFeed/Controllers/frontController.cs @@ -27,13 +27,13 @@ public frontController() : base() [Route("", Order = 1)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task index() { return await indexPage(1); } [Route("page-{page:int:min(2)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")] #endif public async Task indexPage(int page) { @@ -54,7 +54,7 @@ public async Task indexPage(int page) [Route("group/{major}.{minor}.{number}.{revision}/")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task viewGroup(byte major, byte minor, ushort number, ushort? revision = null) { @@ -73,7 +73,7 @@ public async Task viewGroup(byte major, byte minor, ushort number, [Route("build/{id:guid}/", Name = "Build")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task viewBuild(Guid id) { @@ -90,7 +90,7 @@ public async Task viewBuild(long id) [Route("twitter/{id}/")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none")] +// [OutputCache(Duration = 600, VaryByParam = "none")] [CustomContentType(ContentType = "image/png", Order = 2)] #endif public async Task twitterCard(Guid id) @@ -126,13 +126,13 @@ public async Task twitterCard(Guid id) [Route("lab/{lab}/", Order = 1, Name = "Lab Root")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task viewLab(string lab) { return await viewLabPage(lab, 1); } [Route("lab/{lab}/page-{page:int:min(2)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")] #endif public async Task viewLabPage(string lab, int page) { @@ -158,13 +158,13 @@ public async Task viewLabPage(string lab, int page) [Route("source/{source}/", Order = 1, Name = "Source Root")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task viewSource(TypeOfSource source) { return await viewSourcePage(source, 1); } [Route("source/{source}/page-{page:int:min(2)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")] #endif public async Task viewSourcePage(TypeOfSource source, int page) { @@ -190,13 +190,13 @@ public async Task viewSourcePage(TypeOfSource source, int page) [Route("year/{year}/", Order = 1, Name = "Year Root")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task viewYear(int year) { return await viewYearPage(year, 1); } [Route("year/{year}/page-{page:int:min(2)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")] #endif public async Task viewYearPage(int year, int page) { @@ -222,13 +222,13 @@ public async Task viewYearPage(int year, int page) [Route("version/{major}.{minor}/", Order = 1, Name = "Version Root")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task viewVersion(int major, int minor) { return await viewVersionPage(major, minor, 1); } [Route("version/{major}.{minor}/page-{page:int:min(2)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task viewVersionPage(int major, int minor, int page) { diff --git a/BuildFeed/Controllers/supportController.cs b/BuildFeed/Controllers/supportController.cs index 506228b..865288d 100644 --- a/BuildFeed/Controllers/supportController.cs +++ b/BuildFeed/Controllers/supportController.cs @@ -143,7 +143,7 @@ public async Task rss() [Route("sitemap/")] #if !DEBUG - [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task sitemap() { @@ -288,7 +288,7 @@ group b by b.Lab into lab [Route("xml-sitemap/")] #if !DEBUG - [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task xmlsitemap() { @@ -326,7 +326,7 @@ public async Task xmlsitemap() [Route("statistics/")] #if !DEBUG - [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")] +// [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")] #endif public async Task stats() { diff --git a/BuildFeed/Global.asax.cs b/BuildFeed/Global.asax.cs index 843fe4f..270c862 100644 --- a/BuildFeed/Global.asax.cs +++ b/BuildFeed/Global.asax.cs @@ -6,34 +6,36 @@ namespace BuildFeed { - public class MvcApplication : System.Web.HttpApplication - { - protected void Application_Start() - { - // Don't bother looking for the legacy aspx view engine. - ViewEngines.Engines.Clear(); - ViewEngines.Engines.Add(new RazorViewEngine()); + public class MvcApplication : System.Web.HttpApplication + { + protected void Application_Start() + { + // Don't bother looking for the legacy aspx view engine. + ViewEngines.Engines.Clear(); + ViewEngines.Engines.Add(new RazorViewEngine()); - AreaRegistration.RegisterAllAreas(); - FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); - RouteConfig.RegisterRoutes(RouteTable.Routes); - BundleConfig.RegisterBundles(BundleTable.Bundles); + AreaRegistration.RegisterAllAreas(); + FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); + RouteConfig.RegisterRoutes(RouteTable.Routes); + BundleConfig.RegisterBundles(BundleTable.Bundles); - DateTimeModelBinder db = new DateTimeModelBinder(); + DateTimeModelBinder db = new DateTimeModelBinder(); - ModelBinders.Binders.Add(typeof(DateTime), db); - ModelBinders.Binders.Add(typeof(DateTime?), db); - } + ModelBinders.Binders.Add(typeof(DateTime), db); + ModelBinders.Binders.Add(typeof(DateTime?), db); + } - public override string GetVaryByCustomString(HttpContext context, string custom) - { - switch(custom) - { - case "userName": - return context.User.Identity.Name.ToLower(); - } + public override string GetVaryByCustomString(HttpContext context, string custom) + { + switch (custom) + { + case "userName": + return context.User.Identity.Name.ToLower(); + case "lang": + return context.Request.Cookies["lang"].Value; + } - return ""; - } - } + return ""; + } + } }