Handle static caching better#76
Merged
Merged
Conversation
There was a problem hiding this comment.
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
/!/nocacherequests and hydratesparams/urlinputs from theurlbody field (supporting both custom-query-string and query-string modes). LivewireCollection::resolveCurrentPathnow uses the target URL from a nocache request to derivecurrentPathinstead of the literal/!/nocachepath.- 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); |
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.
No description provided.