Skip to content

Commit cb4f839

Browse files
committed
add cache-control header to prevent checkout pages from being cached.
1 parent 5ca4a8e commit cb4f839

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Microsoft.AspNetCore.Mvc.Filters;
2+
3+
namespace Umbraco.Commerce.Checkout.Web.Controllers.Filters
4+
{
5+
/// <summary>
6+
/// Add "cache-control: no-store" header to the response.
7+
/// </summary>
8+
internal sealed class NoStoreCacheControlAttribute : ActionFilterAttribute
9+
{
10+
public override void OnActionExecuted(ActionExecutedContext context)
11+
{
12+
context.HttpContext.Response.Headers.CacheControl = "no-store";
13+
}
14+
}
15+
}

src/Umbraco.Commerce.Checkout/Web/Controllers/UmbracoCommerceCheckoutBaseController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
using Umbraco.Cms.Core.Models.PublishedContent;
77
using Umbraco.Cms.Web.Common.Controllers;
88
using Umbraco.Extensions;
9+
using Umbraco.Commerce.Checkout.Web.Controllers.Filters;
910

1011
namespace Umbraco.Commerce.Checkout.Web.Controllers
1112
{
13+
[NoStoreCacheControl]
1214
public abstract class UmbracoCommerceCheckoutBaseController : RenderController
1315
{
1416
public UmbracoCommerceCheckoutBaseController(ILogger<UmbracoCommerceCheckoutBaseController> logger, ICompositeViewEngine compositeViewEngine, IUmbracoContextAccessor umbracoContextAccessor)

0 commit comments

Comments
 (0)