Add the current culture to the cache key used for the CachedPartial Html Helper

when using variants it's unlikely to need the same Html.Partial to be cached across all language variations, if we always add the current culture name to the cache key, we ensure this doesn't accidentally happen, and when not using variants, no harm to have the culture for the single site included here
This commit is contained in:
Marc Goodson
2020-06-28 18:08:03 +01:00
committed by Sebastiaan Janssen
parent 9f9cd0e11e
commit 6b5e19fcf2

View File

@@ -83,6 +83,12 @@ namespace Umbraco.Web
Func<object, ViewDataDictionary, string> contextualKeyBuilder = null)
{
var cacheKey = new StringBuilder(partialViewName);
//let's always cache by the current culture to allow variants to have different cache results
var cultureName = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
if (!String.IsNullOrEmpty(cultureName))
{
cacheKey.AppendFormat("{0}-", cultureName);
}
if (cacheByPage)
{
if (Current.UmbracoContext == null)