Implement Automated Varnish Cache Purge for Posts, Pages, CPTs & Sitemaps#11
Open
aayris wants to merge 1 commit intocloudpanel-io:masterfrom
Open
Implement Automated Varnish Cache Purge for Posts, Pages, CPTs & Sitemaps#11aayris wants to merge 1 commit intocloudpanel-io:masterfrom
aayris wants to merge 1 commit intocloudpanel-io:masterfrom
Conversation
|
When WooCommerce and Elementor work together, they remember old files like post-131.css used on the homepage when they change. This needs to be triggered when Elementor generates new CSS, which is a significant issue. |
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.
Summary
This pull request introduces automatic Varnish cache purging whenever WordPress content is updated.
The feature ensures that edited or newly published posts, pages, and public custom post types immediately trigger Varnish to purge the related URL(s).
To maintain indexing accuracy, this PR also purges WordPress, Yoast, and Rank-Math style sitemap URLs.
Key Features
🔄 Automatic cache purge on publish/update for:
🗺️ Automatic sitemap purge, including:
🔐 Only purges when Varnish cache is enabled in plugin settings
📝 Ignores autosaves and revisions
🎯 Triggers only for public post types
🎉 Displays a success notice in the WordPress admin after purge
🧩 All logic added inside a dedicated class:
class.varnish-cache-purge.php🧼 Minimal changes to the main plugin loader
🔄 Fully backward-compatible
Implementation Details
A new file was introduced:
class.varnish-cache-purge.phpThis class:
The main plugin file (clp-varnish-cache.php) was updated to load and initialize this class.
All logic follows WordPress coding standards and CloudPanel’s plugin structure.
Testing Performed
Verified auto-purge is triggered correctly under CloudPanel + Varnish
Confirmed sitemap purge execution
Tested on:
Verified skip conditions:
Confirmed no errors in admin settings page
Confirmed purges only occur when the plugin’s Enable Varnish Cache option is enabled
Why This Improvement Matters
Backward Compatibility
This update introduces no breaking changes:
The feature is additive, safe, and optional (depends on “Enable Varnish Cache” setting).