Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRQ-33855 : Added localization id to cache key #105

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sdl.Web.Mvc/OutputCache/DXAOutputCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public override void OnResultExecuted(ResultExecutedContext ctx)
private static string CalcCacheKey(ActionExecutingContext ctx)
{
var sb = new StringBuilder();
sb.Append($"{ctx.ActionDescriptor.UniqueId}-{ctx.HttpContext.Request.Url}-{ctx.HttpContext.Request.UserAgent}:{WebRequestContext.CacheKeySalt}");
sb.Append($"{ctx.ActionDescriptor.UniqueId}-{WebRequestContext.Localization.Id}-{ctx.HttpContext.Request.Url}-{ctx.HttpContext.Request.UserAgent}:{WebRequestContext.CacheKeySalt}");
foreach (var p in ctx.ActionParameters.Where(p => p.Value != null))
{
sb.Append($"{p.Key.GetHashCode()}:{p.Value.GetHashCode()}-");
Expand All @@ -191,10 +191,10 @@ private static void SetDisablePageOutputCache(ControllerContext ctx, bool disabl
private static string GetKey(ControllerContext ctx)
{
string key = "__dxa__";
if (ctx.IsChildAction) key += "c";
if (ctx.IsChildAction) key += "c";
ViewModel model = ctx.Controller.ViewData.Model as ViewModel;
if (model == null) return key;
key += model.GetHashCode();
key += $"{WebRequestContext.Localization.Id}-{model.GetHashCode()}";
return key;
}

Expand Down
2 changes: 1 addition & 1 deletion Sdl.Web.Tridion/Providers/DefaultContentProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public virtual PageModel GetPageModel(string urlPath, Localization localization,
if (CacheRegions.IsViewModelCachingEnabled)
{
PageModel cachedPageModel = SiteConfiguration.CacheProvider.GetOrAdd(
$"{urlPath}:{addIncludes}:{WebRequestContext.CacheKeySalt}", // Cache Page Models with and without includes separately
$"{localization.Id}:{urlPath}:{addIncludes}:{WebRequestContext.CacheKeySalt}", // Cache Page Models with and without includes separately
CacheRegions.PageModel,
() =>
{
Expand Down
Loading