Skip to content

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Came up via an internal support request.

Description

It's been identified that in Umbraco 13 we specifically disabled caching on any backoffice API requests, but we don't do the same on the management API. Although there's no evidence this has caused issues with usage via the backoffice, this can lead to cached responses being returned when a CDN is in the mix.

As such I've added the existing attribute for disabling the browser cache to the base management API controller.

Testing

Verify the headers you see on the response.

Before:
image

After:
image

Copilot AI review requested due to automatic review settings June 6, 2025 10:08
@AndyButland AndyButland changed the title Adds attribute to ensure management API requests are never cached in the browser or via a CDN. Adds attribute to ensure management API requests are never cached in the browser or via a CDN Jun 6, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that all Management API requests include headers to prevent caching in browsers or CDNs by applying the existing DisableBrowserCache filter on the base controller.

  • Adds the DisableBrowserCache attribute to ManagementApiControllerBase
  • Imports the necessary filter namespace
Comments suppressed due to low confidence (1)

src/Umbraco.Cms.Api.Management/Controllers/ManagementApiControllerBase.cs:26

  • Consider adding an automated or integration test to verify that responses from Management API endpoints include the appropriate no-cache headers (Cache-Control, Pragma, etc.) when this attribute is applied.
[DisableBrowserCache]

Copy link
Contributor

@nikolajlauridsen nikolajlauridsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@nikolajlauridsen nikolajlauridsen enabled auto-merge (squash) June 6, 2025 10:25
@nikolajlauridsen nikolajlauridsen merged commit 6c769d6 into main Jun 6, 2025
26 checks passed
@nikolajlauridsen nikolajlauridsen deleted the v16/improvement/disable-cache-for-mgmt-api branch June 6, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants