Skip to content

fix(Cache): Added subkey to page cache to include contentlet information (Live mode only) + Clean up cache logic#34507

Open
ihoffmann-dot wants to merge 2 commits intomainfrom
issue-34405
Open

fix(Cache): Added subkey to page cache to include contentlet information (Live mode only) + Clean up cache logic#34507
ihoffmann-dot wants to merge 2 commits intomainfrom
issue-34405

Conversation

@ihoffmann-dot
Copy link

@ihoffmann-dot ihoffmann-dot commented Feb 4, 2026

Summary

Added a subkey to page cache to include contentlet information (Live mode only) and cleaned up cache logic to improve caching efficiency.

Changes

  • Added contentletsKey generation based on contentlet identifiers in containers
  • Implemented cache cleanup mechanism to remove old versions of cached pages
  • Implemented the remove method in StaticPageCacheImpl
  • Added SystemCache usage for tracking last cached page keys

Motivation

The issue addressed by this PR is caused by the lack of a mechanism to identify changes made to contentlets (additions, reordering, or deletions) within a Page and have those changes properly reflected in LIVE mode, in Traditional DotCMS. As a result, incorrect information can be displayed and we can have inconsistency between LIVE mode and the actual page.

These changes improve the page caching mechanism by including contentlet information in the cache key, allowing for more precise cache invalidation and better handling of page variations based on their content.

Related Issue

Fixes [DEFECT] Browser displays unpublished version of pages, not respecting Live mode #34405


//Remove from block cache.
CacheLocator.getBlockPageCache().remove(htmlPage);
// CacheLocator.getBlockPageCache().remove(htmlPage);
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this line commented?

Copy link
Author

Choose a reason for hiding this comment

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

This method was being called but was not implemented, so it wasn’t doing anything. I can remove the line directly if needed

@nollymar nollymar requested a review from wezell February 4, 2026 22:54
* @param htmlPage the IHTMLPage
* @param request the HttpServletRequest
*/
private void cleanOldCachedPages(long langId, IHTMLPage htmlPage, HttpServletRequest request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we add test to this new method?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, we don't need this method - the Page cache uses a TTL and evicts the expired entries automatically.

@@ -153,7 +155,7 @@ public final void serve(final OutputStream out) throws DotDataException, IOExcep

}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need any of this code. Instead, in the VelocityUtil.shouldPageCache we need to check if we are in AdminMode and if so, return false. We should never be caching a page from the backend.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, Will. We have been caching pages in the BE for a while, and we have recently discovered some odd behaviors in UVE that disappear when we flush the cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[DEFECT] Browser displays unpublished version of pages, not respecting Live mode

4 participants