-
-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nocache-Tags not being replaced sometimes when URL contains query parameters #11543
Comments
Are you able to provide your |
Yes of course, it's a fresh install using the <?php
return [
/*
|--------------------------------------------------------------------------
| Active Static Caching Strategy
|--------------------------------------------------------------------------
|
| To enable Static Caching, you should choose a strategy from the ones
| you have defined below. Leave this null to disable static caching.
|
*/
'strategy' => env('STATAMIC_STATIC_CACHING_STRATEGY', null),
/*
|--------------------------------------------------------------------------
| Caching Strategies
|--------------------------------------------------------------------------
|
| Here you may define all of the static caching strategies for your
| application as well as their drivers.
|
| Supported drivers: "application", "file"
|
*/
'strategies' => [
'half' => [
'driver' => 'application',
'expiry' => null,
],
'full' => [
'driver' => 'file',
'path' => public_path('static'),
'lock_hold_length' => 0,
'permissions' => [
'directory' => 0755,
'file' => 0644,
],
],
],
/*
|--------------------------------------------------------------------------
| Exclusions
|--------------------------------------------------------------------------
|
| Here you may define a list of URLs to be excluded from static
| caching. You may want to exclude URLs containing dynamic
| elements like contact forms, or shopping carts.
|
*/
'exclude' => [
'class' => null,
'urls' => [
//
],
],
/*
|--------------------------------------------------------------------------
| Invalidation Rules
|--------------------------------------------------------------------------
|
| Here you may define the rules that trigger when and how content would be
| flushed from the static cache. See the documentation for more details.
| If a custom class is not defined, the default invalidator is used.
|
| https://statamic.dev/static-caching
|
*/
'invalidation' => [
'class' => null,
'rules' => [
//
],
],
/*
|--------------------------------------------------------------------------
| Ignoring Query Strings
|--------------------------------------------------------------------------
|
| Statamic will cache pages of the same URL but with different query
| parameters separately. This is useful for pages with pagination.
| If you'd like to ignore the query strings, you may do so.
|
*/
'ignore_query_strings' => false,
'allowed_query_strings' => [
//
],
'disallowed_query_strings' => [
//
],
/*
|--------------------------------------------------------------------------
| Nocache
|--------------------------------------------------------------------------
|
| Here you may define where the nocache data is stored.
|
| https://statamic.dev/tags/nocache#database
|
| Supported drivers: "cache", "database"
|
*/
'nocache' => 'cache',
'nocache_js_position' => 'body',
/*
|--------------------------------------------------------------------------
| Replacers
|--------------------------------------------------------------------------
|
| Here you may define replacers that dynamically replace content within
| the response. Each replacer must implement the Replacer interface.
|
*/
'replacers' => [
\Statamic\StaticCaching\Replacers\CsrfTokenReplacer::class,
\Statamic\StaticCaching\Replacers\NoCacheReplacer::class,
],
/*
|--------------------------------------------------------------------------
| Warm Queue
|--------------------------------------------------------------------------
|
| Here you may define the queue name and connection
| that will be used when warming the static cache.
|
*/
'warm_queue' => env('STATAMIC_STATIC_WARM_QUEUE'),
'warm_queue_connection' => env('STATAMIC_STATIC_WARM_QUEUE_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Shared Error Pages
|--------------------------------------------------------------------------
|
| You may choose to share the same statically generated error page across
| all errors. For example, the first time a 404 is encountered it will
| be generated and cached, and then served for all subsequent 404s.
|
| This is only supported for half measure.
|
*/
'share_errors' => false,
]; .env Config:
|
Thanks! |
@duncanmcclean I just ran into this issue too and your PR resolves this. Is there an ETA on release? This is blocking us from a release because without static caching we have a handful of pages that are just too slow and your PR resolves it for good in all cases we tested. |
Sorry, we don't have an ETA for when it'll be merged. If you need the fix in the meantime, you can pull the PR into your project with a composer patch. |
Bug description
We have set up a multi-site with full static caching enabled for our customer. Some regions of the website are dynamic and are replaced using the nocache tag. This setup works well, but recently, our customer reported a bug:
They launched a marketing campaign targeting a landing page on their website.
https://www.example.com/campaign?utm_source=linkedin.com&utm_medium=referral&utm_campaign=returnonprevention
?utm_campaign=returnonprevention&utm_medium=referral&utm_source=linkedin.com
resolves the issue.Commenting out this line inside the NoCache Controller fixes the problem:
GitHub link
It seems that this line reorders the query parameters, preventing the nocache tags from being replaced correctly.
How to reproduce
Logs
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
It might have something to do with this PR: #7486
The text was updated successfully, but these errors were encountered: