public static SpeedyLayoutModel GetSpeedyLayoutModel() { string text = GetPageKey(HttpContext.Current.Request.Url.AbsolutePath) + "speedysettings"; SpeedyLayoutModel speedyModel = HttpContext.Current.Cache[text] as SpeedyLayoutModel; if (speedyModel != null) { return(speedyModel); } SpeedyLayoutModel model = new SpeedyLayoutModel(); model.CacheKey = text; model.SpeedyEnabled = SpeedyGenerationSettings.IsSpeedyEnabledForPage(Sitecore.Context.Item); model.SpeedyJsEnabled = false; model.SpeedyCssEnabled = false; bool isOnePassCookieEnabledAndPresent = SpeedyGenerationSettings.IsOnePassCookieEnabled(Sitecore.Context.Item) && !string.IsNullOrWhiteSpace(HttpContext.Current.Request[SpeedyConstants.CookieNames.OnePassCookieName]); model.ByPassNotDetected = string.IsNullOrWhiteSpace(HttpContext.Current.Request[SpeedyConstants.ByPass.ByPassParameter]) && !isOnePassCookieEnabledAndPresent; if (!model.ByPassNotDetected) { model.SpeedyEnabled = false; } if (model.SpeedyEnabled && model.ByPassNotDetected) { model.AssetLinks = GenerateDeferedLinks(new ThemesProvider()); model.SpeedyJsEnabled = SpeedyGenerationSettings.IsCriticalJavascriptEnabledAndPossible(Sitecore.Context.Item); model.SpeedyCssEnabled = SpeedyGenerationSettings.IsCriticalStylesEnabledAndPossible(Sitecore.Context.Item); if (model.SpeedyCssEnabled) { model.CriticalHtml = Sitecore.Context.Item.Fields[SpeedyConstants.Fields.CriticalCss].Value; model.SpecialCaseCriticalCss = Sitecore.Context.Item.Fields[SpeedyConstants.Fields.SpecialCaseCriticalCss].Value; } } else { model.AssetLinks = AssetLinksGenerator.GenerateLinks(new ThemesProvider()); } return(model); }
public static SpeedyLayoutModel GetSpeedyLayoutModel() { string text = GetPageKey(HttpContext.Current.Request.Url.AbsolutePath) + "speedysettings"; SpeedyLayoutModel speedyModel = HttpContext.Current.Cache[text] as SpeedyLayoutModel; if (SpeedyGenerationSettings.IsDebugModeEnabled()) { speedyModel = null; } if (speedyModel != null) { return(speedyModel); } SpeedyLayoutModel model = new SpeedyLayoutModel(); model.CacheKey = text; model.SpeedyEnabled = SpeedyGenerationSettings.IsSpeedyEnabledForPage(Sitecore.Context.Item); model.SpeedyJsEnabled = false; model.SpeedyCssEnabled = false; bool isOnePassCookieEnabledAndPresent = SpeedyGenerationSettings.IsOnePassCookieEnabled(Sitecore.Context.Item) && !string.IsNullOrWhiteSpace(HttpContext.Current.Request[SpeedyConstants.CookieNames.OnePassCookieName]); model.ByPassNotDetected = string.IsNullOrWhiteSpace(HttpContext.Current.Request[SpeedyConstants.ByPass.ByPassParameter]) && !isOnePassCookieEnabledAndPresent; if (!model.ByPassNotDetected) { model.SpeedyEnabled = false; } model.VanillaJavasriptAllLoads = GetVanillaJavascriptAllLoades(); if (model.SpeedyEnabled && model.ByPassNotDetected) { BuildSpeedy(model); } else { model.AssetLinks = AssetLinksGenerator.GenerateLinks(new ThemesProvider()); } return(model); }