The GetVaryByCustomString method is not fired when I place a breakpoint in it.
The action I want to cache depending on the language the user selected:
[OutputCache(CacheProfile = "24HoursCache", VaryByCustom = "lang")]
public ActionResult MyAction()
{
...
}
The cache profile in the Web.config:
<configuration>
...
<system.web>
...
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<clear />
<add name="24HoursCache" duration="86400" location="Client" varyByParam="none" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
...
</configuration>
And in the Global.asax.cs file:
public override string GetVaryByCustomString(HttpContext context, string value)
{
if (value.ToLower() == "lang")
{
return Thread.CurrentThread.CurrentUICulture.Name;
}
return base.GetVaryByCustomString(context, value);
}
Any help would be appreciated, thanks!
Actually location must be set to "Server", and not "Client".
And it works, phew!