Last active
November 2, 2020 14:50
-
-
Save trnktms/eea964dbcb97a959a4ccaad1fe09fb22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Discovering.Sitecore10.Caching | |
{ | |
public class OutputCacheOptions | |
{ | |
public bool Enabled { get; set; } | |
} | |
[HtmlTargetElement("sitecore-output-cache")] | |
public class OutputCacheTagHelper : CacheTagHelper | |
{ | |
public OutputCacheTagHelper( | |
CacheTagHelperMemoryCacheFactory factory, | |
HtmlEncoder htmlEncoder, | |
IHttpContextAccessor httpContextAccessor, | |
IOptions<OutputCacheOptions> cachingOptions, | |
IOutputCacheService outputCacheService) | |
: base(factory, htmlEncoder) | |
{ | |
ExpiresOn = DateTimeOffset.MaxValue; | |
VaryBy = httpContextAccessor.HttpContext.Request.Path + "," + outputCacheService.GetLastCacheReload().ToString(CultureInfo .InvariantCulture); | |
Enabled = cachingOptions.Value.Enabled; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment