From c9985f004335f426017feea016a3c208edb41b7e Mon Sep 17 00:00:00 2001 From: Mole Date: Thu, 15 Oct 2020 08:58:01 +0200 Subject: [PATCH] Remove DisableBrowserCacheAttribute --- src/Umbraco.Web/Umbraco.Web.csproj | 1 - .../Filters/DisableBrowserCacheAttribute.cs | 42 ------------------- .../WebApi/UmbracoAuthorizedApiController.cs | 6 +-- 3 files changed, 3 insertions(+), 46 deletions(-) delete mode 100644 src/Umbraco.Web/WebApi/Filters/DisableBrowserCacheAttribute.cs diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 8e9d40ccb4..e7f10ad0db 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -275,7 +275,6 @@ - diff --git a/src/Umbraco.Web/WebApi/Filters/DisableBrowserCacheAttribute.cs b/src/Umbraco.Web/WebApi/Filters/DisableBrowserCacheAttribute.cs deleted file mode 100644 index cfb7ddb6bc..0000000000 --- a/src/Umbraco.Web/WebApi/Filters/DisableBrowserCacheAttribute.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Net.Http.Headers; -using System.Web.Http.Filters; - -namespace Umbraco.Web.WebApi.Filters -{ - /// - /// Ensures that the request is not cached by the browser - /// - public class DisableBrowserCacheAttribute : ActionFilterAttribute - { - public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) - { - //See: http://stackoverflow.com/questions/17755239/how-to-stop-chrome-from-caching-rest-response-from-webapi - - base.OnActionExecuted(actionExecutedContext); - if (actionExecutedContext == null || actionExecutedContext.Response == null || - actionExecutedContext.Response.Headers == null) - { - return; - } - //NOTE: Until we upgraded to WebApi 2, this didn't work correctly and we had to revert to using - // HttpContext.Current responses. I've changed this back to what it should be now since it works - // and now with WebApi2, the HttpContext.Current responses don't! Anyways, all good now. - actionExecutedContext.Response.Headers.CacheControl = new CacheControlHeaderValue() - { - NoCache = true, - NoStore = true, - MaxAge = new TimeSpan(0), - MustRevalidate = true - }; - - actionExecutedContext.Response.Headers.Pragma.Add(new NameValueHeaderValue("no-cache")); - if (actionExecutedContext.Response.Content != null) - { - actionExecutedContext.Response.Content.Headers.Expires = - //Mon, 01 Jan 1990 00:00:00 GMT - new DateTimeOffset(1990, 1, 1, 0, 0, 0, TimeSpan.Zero); - } - } - } -} diff --git a/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs index 993fd36bc2..87627501bd 100644 --- a/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs +++ b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs @@ -23,9 +23,9 @@ namespace Umbraco.Web.WebApi [IsBackOffice] // [UmbracoUserTimeoutFilter] has been migrated to netcore [UmbracoAuthorize] - [DisableBrowserCache] - // [UmbracoWebApiRequireHttps] - // [CheckIfUserTicketDataIsStale] + // [DisableBrowserCache] has been migrated to netcore + // [UmbracoWebApiRequireHttps] + // [CheckIfUserTicketDataIsStale] // [UnhandedExceptionLoggerConfiguration] [EnableDetailedErrors] public abstract class UmbracoAuthorizedApiController : UmbracoApiController