diff --git a/test/WebSites/HtmlGenerationWebSite/Pages/CacheTagHelper_VaryByCulture.cshtml b/test/WebSites/HtmlGenerationWebSite/Pages/CacheTagHelper_VaryByCulture.cshtml
index bdf54e5728..97cb7f7d52 100644
--- a/test/WebSites/HtmlGenerationWebSite/Pages/CacheTagHelper_VaryByCulture.cshtml
+++ b/test/WebSites/HtmlGenerationWebSite/Pages/CacheTagHelper_VaryByCulture.cshtml
@@ -1,4 +1,5 @@
@page
+@addTagHelper *, HtmlGenerationWebSite
@using System.Globalization
@functions
{
@@ -9,6 +10,6 @@
@CultureInfo.CurrentCulture
@CultureInfo.CurrentUICulture
@CorrelationId
-
+
@CorrelationId
-
+
diff --git a/test/WebSites/HtmlGenerationWebSite/TestCacheTagHelper.cs b/test/WebSites/HtmlGenerationWebSite/TestCacheTagHelper.cs
new file mode 100644
index 0000000000..e8f710d17e
--- /dev/null
+++ b/test/WebSites/HtmlGenerationWebSite/TestCacheTagHelper.cs
@@ -0,0 +1,48 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Text.Encodings.Web;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc.TagHelpers;
+using Microsoft.AspNetCore.Mvc.TagHelpers.Cache;
+using Microsoft.AspNetCore.Mvc.TagHelpers.Internal;
+using Microsoft.AspNetCore.Razor.TagHelpers;
+using Microsoft.Extensions.Logging;
+
+namespace HtmlGenerationWebSite
+{
+ // This TagHelper enables us to investigate potential flakiness in the test that uses this tracked by https://github.com/aspnet/Mvc/issues/8281
+ public class TestCacheTagHelper : CacheTagHelper
+ {
+ private readonly ILogger _logger;
+
+ public TestCacheTagHelper(
+ CacheTagHelperMemoryCacheFactory factory,
+ HtmlEncoder htmlEncoder,
+ ILoggerFactory loggerFactory) : base(factory, htmlEncoder)
+ {
+ if (loggerFactory == null)
+ {
+ throw new ArgumentNullException(nameof(loggerFactory));
+ }
+
+ _logger = loggerFactory.CreateLogger();
+ }
+
+ public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ {
+ var cacheKey = new CacheTagKey(this, context);
+ if (MemoryCache.TryGetValue(cacheKey, out var _))
+ {
+ _logger.LogInformation("Cache entry exists with key: " + cacheKey.GenerateKey());
+ }
+ else
+ {
+ _logger.LogInformation("Cache entry does NOT exist with key: " + cacheKey.GenerateKey());
+ }
+
+ return base.ProcessAsync(context, output);
+ }
+ }
+}