Skip to content

Commit

Permalink
Merge pull request #105 from RWS/feature/CRQ-33855
Browse files Browse the repository at this point in the history
CRQ-33855 : Added localization id to cache key
  • Loading branch information
majiccode authored May 23, 2023
2 parents 23578bf + cac9c29 commit 4f3721d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 4f3721d

Please sign in to comment.