Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbruggmann
Copy link

added new options cookieParams.respect and queryParams.respect which work the opposite way the options cookieParams.ignore and queryParams.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.

…t add cookies and arguments which affect the caching. which makes configuration much easier.
Copy link
Member

@mficzel mficzel left a 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.

Copy link
Member

@mficzel mficzel left a 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)):
Copy link
Member

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.

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?

@mficzel mficzel changed the title inverted cache disabling to cache FEATURE: Add Setting queryParams|cookieParams.respect to invert the control Oct 18, 2023
@lorenzulrich
Copy link

@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: []
Copy link
Contributor

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 🤔

Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

paavo reviewed yesterday

Oh, i just wanted to drop a comment 🙈 😆
Nothing reviewed so far 😆

Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Member

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 ...

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.

None yet

5 participants