fix(feed-display): fix static cache key collision with multiple plugin instances - #16
Open
dkd-hauser wants to merge 1 commit into
Open
fix(feed-display): fix static cache key collision with multiple plugin instances#16dkd-hauser wants to merge 1 commit into
dkd-hauser wants to merge 1 commit into
Conversation
…n instances ## Problem The `FeedController` uses a hardcoded cache key (`feeddisplay`) shared across all plugin instances regardless of their individual settings (feed URL, date range, type etc.). With multiple instances configured with different settings, every request that hits an instance whose settings differ from the currently cached ones causes a cache miss and overwrites the shared cache entry. In practice this means caching is completely ineffective when more than one instance is deployed.
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.
Problem
The
FeedControlleruses a hardcoded cache key (feeddisplay) shared across all plugin instances regardless of their individual settings (feed URL, date range, type etc.).When more than one plugin element is configured with different settings, every request that hits an element whose settings differ from the currently cached ones causes a cache miss and overwrites the shared cache entry.
In practice this means caching is completely ineffective when multiple plugin elements with different settings are used on the same website.
Root Cause
The settings comparison on line 45 (
$data['settings'] !== $this->settings) was clearly intended to compensate for this, but has the opposite effect when multiple plugin elements are configured with different settings: each element invalidates the cache of every other.Fix
Generate an instance-specific cache key based on an MD5 hash of the resolved plugin settings:
$cacheIdentifier = 'feeddisplay_' . md5(serialize($this->settings));This gives each uniquely configured plugin element its own stable cache entry that is only rebuilt when its own settings change.