Skip to content

Conversation

@marcorieser
Copy link
Contributor

@marcorieser marcorieser commented Oct 29, 2025

This PR allows Cache Tags to be enabled not only for GET but POST requests.

Backstory
I've detected that Cache Tags are not enabled for POST requests (Livewire subsequent requests), and had a little chat with Duncan about how I could support that in the Livewire addon. We came up with three approaches:

  1. We add another condition to check if the request URL matches the Livewire update URL:
private function isEnabled()
{
    if (! config('statamic.system.cache_tags_enabled', true)) {
        return false;
    }

    if (request()->isLivePreview()) {
        return false;
    }

    // THIS
    if (request()->getRequestUri() === Livewire::getUpdateUri()) {
        return true;
    }

    // Only GET requests.
    return request()->method() === 'GET';
}
  1. We make Tags/Cache::isEnabled() protected, I extend the cache tag in the Livewire addon, and overwrite that method with the check from the first approach
  2. We allow all request types, since we have a dedicated check for Live Preview now (bab7822), which was probably the original reason for disabling it for POST requests. (Implemented approach)

Fixes: #12909

@jasonvarga jasonvarga merged commit 9b7d759 into statamic:5.x Oct 29, 2025
26 checks passed
@marcorieser marcorieser deleted the fix/enable-cache-tag-for-post-requests branch November 1, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache Tag not working in Livewire / POST requests

2 participants