Remove DisableBrowserCacheAttribute

This commit is contained in:
Mole
2020-10-15 08:58:01 +02:00
parent 2a048681da
commit c9985f0043
3 changed files with 3 additions and 46 deletions

View File

@@ -275,7 +275,6 @@
<Compile Include="WebApi\AngularJsonMediaTypeFormatter.cs" />
<Compile Include="WebApi\AngularJsonOnlyConfigurationAttribute.cs" />
<Compile Include="WebApi\Filters\AngularAntiForgeryHelper.cs" />
<Compile Include="WebApi\Filters\DisableBrowserCacheAttribute.cs" />
<Compile Include="WebApi\Filters\ValidateAngularAntiForgeryTokenAttribute.cs" />
<Compile Include="Controllers\UmbRegisterController.cs" />
<Compile Include="Models\ProfileModel.cs" />

View File

@@ -1,42 +0,0 @@
using System;
using System.Net.Http.Headers;
using System.Web.Http.Filters;
namespace Umbraco.Web.WebApi.Filters
{
/// <summary>
/// Ensures that the request is not cached by the browser
/// </summary>
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);
}
}
}
}

View File

@@ -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