Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR moves the database cache rebuild operation to a background task with polling to improve user feedback and avoid request timeouts in large sites. Key changes include:
- Modifying the client controller to poll for rebuild status asynchronously.
- Adding a new API endpoint that initiates the rebuild operation on a background thread.
- Updating the snapshot service and interface to support background execution via runtime cache flags.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.controller.js | Updated API endpoint call and added polling logic for asynchronous status updates. |
| src/Umbraco.Web.BackOffice/Controllers/PublishedSnapshotCacheStatusController.cs | Introduced a new POST endpoint for background rebuild with appropriate status checks. |
| src/Umbraco.PublishedCache.NuCache/PublishedSnapshotStatus.cs | Returns a consistent "Rebuild in progress" message while rebuilding. |
| src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs | Modified rebuild operation to use a background task along with runtime cache flagging. |
| src/Umbraco.Core/PublishedCache/IPublishedSnapshotService.cs | Extended the interface to support background rebuild operations. |
Comments suppressed due to low confidence (1)
src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs:36
- [nitpick] The constant name could be more descriptive. Consider renaming it to something like 'DatabaseCacheRebuildLockKey' to better reflect its purpose.
private const string IsRebuildingDatabaseCacheRuntimeCacheKey = "temp_database_cache_rebuild_op";
src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.controller.js
Outdated
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.controller.js
Show resolved
Hide resolved
…edsnapshotcache.controller.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…on-to-submit-and-poll' of https://github.com/umbraco/Umbraco-CMS into v13/task/backport-long-running-database-rebuild-operation-to-submit-and-poll
Migaroez
approved these changes
Apr 3, 2025
Contributor
Migaroez
left a comment
There was a problem hiding this comment.
Works as described and code is sensible
This was referenced Sep 30, 2025
This was referenced Dec 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
This was raised as an issue in Umbraco Cloud for large sites where the time to rebuild the database cache is quite long. It may go over the hard limit imposed by Cloudflare and although the work continues, the user has no indication that it's completed.
We already implemented this for 15 in #18496 but it was felt useful to backport to 13 to support customers on that version.
Description
This PR updates the database cache rebuild operation to move it from a single request/response to a pattern where we submit the task, run in in the background and poll for completion.
It is based on what we are already doing for Examine index rebuilds, so it's a pattern and technique already in use in the CMS that I've just applied to this operation.
Testing
To test you can use the UI under Settings > Published Status and click the Rebuild Database Cache button. If you delete all records from
cmsContentNufirst you can see that they are recreated when the operation is completed.To simulate a long running rebuild operation, you can add a
Thread.Sleep(20000);intoPublishedSnapshotService.PerformRebuild().