Caching: Resolves publish and install issues related to stale cached data retrieval #20640
+45
−2
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
Resolves #20539 and #20630
Description
This PR fixes a couple of regression issues in 16.3 related to state data being retrieved from the cache.
The first issue manifests itself with the retrieval of a published content item in a content published notification handler. The issue reporter has described it well, diagnosed and suggested the fix I've used here. The regression has come about with the introduction of a micro-optimization around constructing
IPublishedContentinstances from the cached models in #19990.With the cache key taking in the version as well as the content ID, we can benefit from the cache for page rendering without incurring this issue in the notification handler.
Issue two shows that if a package that creates content is installed at the same time as Umbraco itself, the created content is not visible on the front-end until a restart of a memory cache reload is carried out. This is happening due to #20209, which is another performance improvement we've added to cache null values for content.
To resolve this one I've ensured the memory cache is cleared following an installation that has run package upgrades. This way we again keep the runtime performance benefit introduced by this behaviour change.
Finally in passing I've improved an installation warning message that occurs (changes the display of "0" to "None", which is more meaningful).
Testing
To test the first issue, create and register a notification handler like the following:
Then publish a document, changing it's name.
Before this fix, you will see the old name in the second message that uses the
IPublishedContentinstance. With the fix in place you'll see the correct, new name.You can also verify that the cache benefit on page rendering remains by running with logging at
Debuglevel (or temporarily amending the log messages inPublishedContentFactory.ToIPublishedContentto beInformationlevel) and noting that for a given content item on a page render it's only constructed the first time.For the second issue, configure
Umbraco.Web.UI.csprojto have a package reference to:And start up Umbraco.
Before the fix you'll find that you'll get a 404 on the home page. After this update you'll see the home page content as expected.