private void AttemptToLoadFromCache() { if (AppSettings.ForceSSL && !URIHelper.IsSSL()) { URIHelper.ForceSSL(); } if (FrameworkSettings.CurrentUser == null && Request.QueryString.Count == 0) { if (Request.HttpMethod == "GET" && (!(bool)BaseMapper.CanConnectToDB || AppSettings.EnableOutputCaching)) { var userSelectedVersion = RenderVersion.HTML; if (BasePage.IsMobile) { userSelectedVersion = RenderVersion.Mobile; } var cacheKey = (userSelectedVersion.ToString() + Request.Url.PathAndQuery).ToLower(); if (AppSettings.EnableLevel1MemoryCaching) { var cacheData = (string)ContextHelper.GetFromCache(cacheKey); if (!string.IsNullOrEmpty(cacheData)) { BaseService.WriteHtml(cacheData + "<!-- Loaded from level 1 - Memory Cache -->"); } } if (AppSettings.EnableLevel2FileCaching) { var cache = FileCacheHelper.GetFromCache(cacheKey); if (!cache.IsError) { var cacheData = cache.GetRawData <string>(); if (!string.IsNullOrEmpty(cacheData)) { BaseService.WriteHtml($"{cacheData} <!-- Loaded from level 2 - File Cache -->"); } } } if (AppSettings.EnableLevel3RedisCaching) { var cacheData = RedisCacheHelper.GetFromCache(cacheKey); if (!string.IsNullOrEmpty(cacheData)) { BaseService.WriteHtml(cacheData + "<!-- Loaded from level 3 - Redis Cache -->"); } } } AttemptDBConnection(); } }
private void AttemptToLoadFromCache() { if (!IsRunningOnLocalHost && AppSettings.ForceSSL && !URIHelper.IsSSL()) { URIHelper.ForceSSL(); } //if (Request.Url.AbsolutePath != "/" && !BasePage.IsAjaxRequest) //{ // Response.Redirect("/#" + Request.Url.PathAndQuery, true); //} if (Request.QueryString.Count == 0 || (Request.QueryString.Count == 1 && Request.QueryString[BasePage.HomePagePath] != null)) { if (Request.HttpMethod == "GET" && ((BaseMapper.CanConnectToDB != null && !(bool)BaseMapper.CanConnectToDB) || AppSettings.EnableOutputCaching)) { var userSelectedVersion = RenderVersion.HTML; if (BasePage.IsMobile) { userSelectedVersion = RenderVersion.Mobile; } var cacheKey = (userSelectedVersion.ToString() + Request.Url.LocalPath).ToLower(); if (AppSettings.EnableLevel1MemoryCaching) { var cacheData = (string)ContextHelper.GetFromCache(cacheKey); if (!string.IsNullOrEmpty(cacheData)) { BaseService.WriteHtml(cacheData + "<!-- Loaded from level 1 - Memory Cache -->"); } } if (AppSettings.EnableLevel2FileCaching) { var cache = FileCacheHelper.GetFromCache(cacheKey); if (!cache.IsError) { var cacheData = cache.GetRawData <string>(); if (!string.IsNullOrEmpty(cacheData)) { BaseService.WriteHtml($"{cacheData} <!-- Loaded from level 2 - File Cache -->"); } } } if (AppSettings.EnableLevel3RedisCaching) { var cacheData = RedisCacheHelper.GetFromCache(cacheKey); if (!string.IsNullOrEmpty(cacheData)) { BaseService.WriteHtml(cacheData + "<!-- Loaded from level 3 - Redis Cache -->"); } } } AttemptDBConnection(); } }