Skip to content

Handle static caching better#76

Merged
afonic merged 2 commits into
masterfrom
fix/static-caching-url-handling
May 17, 2026
Merged

Handle static caching better#76
afonic merged 2 commits into
masterfrom
fix/static-caching-url-handling

Conversation

@afonic

@afonic afonic commented May 17, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds support for Statamic's static-cache "nocache" endpoint (/!/nocache) so the filters package can correctly resolve the target page URL and extract filter parameters when a cached page makes a nocache POST to re-render dynamic regions. Without this, filter state derived from the request path/referer was wrong inside nocache regions.

Changes:

  • Middleware short-circuits for /!/nocache requests and hydrates params/url inputs from the url body field (supporting both custom-query-string and query-string modes).
  • LivewireCollection::resolveCurrentPath now uses the target URL from a nocache request to derive currentPath instead of the literal /!/nocache path.
  • Adds three new feature tests covering nocache path resolution and URL stripping; minor tidy-up of an existing test's formatting/use statement.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Http/Middleware/HandleFiltersQueryString.php New nocache detection and url input hydration logic (params extraction + URL normalization).
src/Http/Livewire/LivewireCollection.php resolveCurrentPath falls back to the nocache url input when present.
tests/Feature/CustomQueryStringTest.php New tests for nocache behavior; small formatting/imports cleanup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +76 to +78
$actionPrefix = trim((string) config('statamic.routes.action', '!'), '/');

return $actionPrefix !== '' && $request->is($actionPrefix.'/nocache');
Comment on lines +155 to +159
foreach ($originalQuery as $key => $value) {
$request->query->set($key, $value);
}

$request->merge($originalQuery);
Comment on lines +95 to +99
if (config('statamic-livewire-filters.enable_query_string') === true) {
$this->hydrateFromOriginalQueryString($request, $parsed);

return;
}

if (! empty($params)) {
$request->merge(['params' => $params]);
$request->query->set('params', $params);

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@afonic afonic merged commit 8e55cf5 into master May 17, 2026
13 checks passed
@afonic afonic deleted the fix/static-caching-url-handling branch May 17, 2026 14:33
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.

2 participants