From f8f0a94c19d4f83992b135141ec3406eba0cf0fb Mon Sep 17 00:00:00 2001 From: Peter Dolkens Date: Fri, 1 Apr 2016 10:44:58 +0100 Subject: [PATCH] Caching tweaks --- HoloXPLOR/Controllers/_BaseController.cs | 8 ++++---- HoloXPLOR/Global.asax.cs | 22 +++++++++++----------- HoloXPLOR/Views/Home/Index.cshtml | 2 +- HoloXPLOR/Views/Shared/_Layout.cshtml | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/HoloXPLOR/Controllers/_BaseController.cs b/HoloXPLOR/Controllers/_BaseController.cs index 107b9ea..75e76f8 100644 --- a/HoloXPLOR/Controllers/_BaseController.cs +++ b/HoloXPLOR/Controllers/_BaseController.cs @@ -77,8 +77,8 @@ private void SetCaching(ActionExecutingContext filterContext) if (rule.IsMatch(filterContext.HttpContext.Request.Url.PathAndQuery)) { filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.Public); - filterContext.HttpContext.Response.Cache.SetExpires(DateTime.Today.AddDays(7)); - filterContext.HttpContext.Response.Cache.SetMaxAge(TimeSpan.FromHours(168)); + filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(10)); + filterContext.HttpContext.Response.Cache.SetMaxAge(TimeSpan.FromDays(7)); filterContext.HttpContext.Response.DisableKernelCache(); return; @@ -86,14 +86,14 @@ private void SetCaching(ActionExecutingContext filterContext) } filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); - filterContext.HttpContext.Response.Cache.SetExpires(DateTime.Now); + filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow); filterContext.HttpContext.Response.Cache.SetMaxAge(TimeSpan.FromMilliseconds(0)); } private RedirectResult RedirectTemporary(AuthorizationContext filterContext, String url) { filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); - filterContext.HttpContext.Response.Cache.SetExpires(DateTime.Now); + filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow); filterContext.HttpContext.Response.Cache.SetMaxAge(TimeSpan.FromMilliseconds(0)); return this.Redirect(url); diff --git a/HoloXPLOR/Global.asax.cs b/HoloXPLOR/Global.asax.cs index 43ff9e5..2a2ff13 100644 --- a/HoloXPLOR/Global.asax.cs +++ b/HoloXPLOR/Global.asax.cs @@ -32,10 +32,10 @@ protected void Application_Start() RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); - String lastBuildFile = HostingEnvironment.MapPath("~/App_Data/lastbuild.txt"); - if (File.Exists(lastBuildFile)) + String latestBuildFile = HostingEnvironment.MapPath("~/App_Data/latestBuild.txt"); + if (File.Exists(latestBuildFile)) { - HoloXPLOR_App._scriptsPath = File.ReadAllText(lastBuildFile); + HoloXPLOR_App._scriptsPath = File.ReadAllText(latestBuildFile); } ThreadStart ts = new ThreadStart(HoloXPLOR_App.CheckForNewBuild); new Thread(ts).Start(); @@ -48,8 +48,10 @@ protected void Application_Start() private static Boolean _stopping = false; private static String _launcherInfo = @"http://manifest.robertsspaceindustries.com/Launcher/_LauncherInfo"; private static DateTime _lastRun; - public static Random _random = new Random(); + private static Random _random = new Random(); + public static String CurrentVersion { get; private set; } + public static Int64 CurrentBuild { get; private set; } public static Scripts Scripts { get; private set; } protected void Application_End() @@ -69,8 +71,6 @@ public static void CheckForNewBuild() Int64 publicBuild = 0; String currentUniverse = String.Empty; - String currentVersion = String.Empty; - Int64 currentBuild = 0; String latestUniverse = String.Empty; String latestVersion = String.Empty; @@ -109,8 +109,8 @@ public static void CheckForNewBuild() if (String.Equals(match.Groups[1].Value, universe, StringComparison.InvariantCultureIgnoreCase)) { currentUniverse = match.Groups[1].Value; - currentVersion = match.Groups[2].Value; - currentBuild = match.Groups[3].Value.ToInt64(0); + HoloXPLOR_App.CurrentVersion = match.Groups[2].Value; + HoloXPLOR_App.CurrentBuild = match.Groups[3].Value.ToInt64(0); } if (match.Groups[3].Value.ToInt64() > latestBuild) @@ -129,7 +129,7 @@ public static void CheckForNewBuild() } } - HoloXPLOR_App.CheckScripts(currentBuild, manifests[currentUniverse]); + HoloXPLOR_App.CheckScripts(HoloXPLOR_App.CurrentBuild, manifests[currentUniverse]); HoloXPLOR_App.HasPTU = publicBuild < latestBuild; } @@ -248,8 +248,8 @@ public static void CheckScripts(Int64 build, String manifestFile) scripts.Localization.Count > 0 && scripts.Vehicles.Count > 0) { - String lastBuildFile = HostingEnvironment.MapPath("~/App_Data/lastbuild.txt"); - File.WriteAllText(lastBuildFile, HoloXPLOR_App._scriptsPath); + String latestBuildFile = HostingEnvironment.MapPath("~/App_Data/latestBuild.txt"); + File.WriteAllText(latestBuildFile, HoloXPLOR_App._scriptsPath); HoloXPLOR_App.Scripts = scripts; } } diff --git a/HoloXPLOR/Views/Home/Index.cshtml b/HoloXPLOR/Views/Home/Index.cshtml index 8c2f442..3788157 100644 --- a/HoloXPLOR/Views/Home/Index.cshtml +++ b/HoloXPLOR/Views/Home/Index.cshtml @@ -20,7 +20,7 @@ }
-

HoloXPLOR - 2.3.0

+

HoloXPLOR - @(HoloXPLOR_App.CurrentVersion) @HoloXPLOR_App.CurrentBuild

HoloXPLOR is your web-based alternative to the Star Citizen Holotable.

diff --git a/HoloXPLOR/Views/Shared/_Layout.cshtml b/HoloXPLOR/Views/Shared/_Layout.cshtml index 6e47fb7..81ec007 100644 --- a/HoloXPLOR/Views/Shared/_Layout.cshtml +++ b/HoloXPLOR/Views/Shared/_Layout.cshtml @@ -113,7 +113,7 @@

- © @DateTime.Now.Year - HoloXPLOR + © @DateTime.Now.Year - HoloXPLOR - @(HoloXPLOR_App.CurrentVersion) @HoloXPLOR_App.CurrentBuild

@*