-
Notifications
You must be signed in to change notification settings - Fork 9
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
FEATURE: Add Setting queryParams|cookieParams.respect
to invert the control
#22
base: main
Are you sure you want to change the base?
FEATURE: Add Setting queryParams|cookieParams.respect
to invert the control
#22
Conversation
…t add cookies and arguments which affect the caching. which makes configuration much easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by reading, i like this better than solutions via cookie name prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think allowedQueryParams
also should only be checked when respectedQueryParams
is empty and the respectedQueryParams
should become part of the generated identifier.
case (in_array($key, $this->ignoredQueryParams) && empty($this->respectedQueryParams)): | ||
$ignoredQueryParams[$key] = $value; | ||
break; | ||
case (!in_array($key, $this->respectedQueryParams) && empty($this->ignoredQueryParams)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a respected queryParameter should be added to $allowedQueryParams[$key]
as i would assume this to be part of the cache identity.
That imho would also mean that allowedQueryParams should only be checked when $this->respectedQueryParams is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mficzel How would you configure FullPageCache to not cache a search query in this case?
queryParams|cookieParams.respect
to invert the control
@sbruggmann I really like this change. Have you seen the comment by Martin? Would you be willing to finish this PR? |
# => If the "search" argument is present in the request, it will not be cached. | ||
# But if a "utm_source" argument is present, the request will be cached as if the argument wouldn't be there. | ||
# Important: Only evaluated if "ignore" is empty! | ||
respect: [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting empty Arrays is a bit nasty, as this will override already set configurations in packages loaded before 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should another package write this config before this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happens all the time when dependencies between packages are not properly declared. Not actually declaring this key but only documenting it helps in those cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's not the business of a package to deal with incorrect dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's not the business of a package to deal with incorrect dependencies.
We have a development package for example, we load in require-dev.
Loading a package there, will reset settings already set in another package.
So i personally prefer to not have empty configurations in configs @Sebobo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paavo but if that package has a "suggest" or "require" on this package, then then merge order is also fine and you won't have problems.
Or is the actual problem using arrays instead of objects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me make an example @Sebobo with Sitegeist.MagicWand:
We have our Site-Package where we define MagicWand Settings clonePresets: ...
.
Then we have a development package we load in require-dev (to only load this on DEV Environments).
This development package requires MagicWand.
And MagicWand sets default clonePresets: []
and overrides the Configuration in the Site-Package.
Or is the actual problem using arrays instead of objects?
The Problem it, that configurations get overridden.
Yes, FullpageCache is probably the opposite of a Dev-Package 😆
But i really prefer not overriding configurations with empty values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then your site package needs also an require-dev
or suggest
entry for your dev package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am undecided wether we should help here. On the one hand it is an easy fix to not actually write the empty config array. On the other hand projects with basically random loading order between interdepending packages will run into issues eventually that are hard to debug. So we may actually do those a favor ...
added new options
cookieParams.respect
andqueryParams.respect
which work the opposite way the optionscookieParams.ignore
andqueryParams.ignore
do.this way we define in the settings which cookies and arguments really matter to our code.
all others don't affect the caching.
especially with tag managers and different tracking we have a lot of changing cookies and arguments which are only meant for the frontend and should never affect the code generation and caching.
we as developers should have the option to just allow known cookies and arguments, and ignore the rest.