Problem/Motivation

Blacklist parameter is a reactive way to ignore parameters sent by traffic sources (GA, Facebook, other social networks).
At the same time, Drupal has well working mechanism of determining what URL parameters are important for the request - it's response cache contexts.

I.e. if a page contains a view with exposed filters, each filter's machine name will be present in response cache contexts list as `url.query_args:`

Proposed resolution

- Add new configuration parameter 'filter_response_context', defaulting to FALSE
- When this parameter is set to TRUE, check if request contains parameters that are not expected by response, and ignore response in this case.

Remaining tasks

Write the patch

User interface changes

No UI changes

API changes

Internal method generateUrlOrPathToRegister() gets additional parameter $response

Comments

valthebald created an issue. See original summary.

valthebald’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new5.4 KB
valthebald’s picture

StatusFileSize
new1.93 KB
new5.51 KB

More fine-grain query string check

valthebald’s picture

Issue summary: View changes
StatusFileSize
new3.31 KB

After testing the filtering approach for a couple of days, it makes sense to throw away ignored parameters (i.e. not queue response for clearing), so the check happens in the same way as blacklist,

lisa.rae’s picture

Status: Needs review » Needs work

Marking Needs Work, patch failed to apply to both dev and rc versions

webflo’s picture

Status: Needs work » Needs review
StatusFileSize
new3.26 KB

I'm going to try it out in a project.

webflo’s picture

StatusFileSize
new3.32 KB

Fixed PHP error, url_to_store not initialized

ericgsmith’s picture

I.e. if a page contains a view with exposed filters, each filter's machine name will be present in response cache contexts list as `url.query_args:`

Are we sure this premise is true? I'm just trying this patch on an existing project and don't see this.

I've got a view with exposed filters, which exposes a taxonomy term with the url query param "type". When I apply this patch and debug the cache contexts I see the more generic url.query_args context is present but nothing specific for type - there is no url.query_args:type. I don't know if that is optimized away at some point or if views isn't adding it - I have not debugged further. With the current patch its then leaves type in the $query_params and the returns NULL, incorrectly skipping this page from the registry.

I need to test this on a clean install / check where cache contexts get optimized as query param garbage is a huge problem for me too / this module and am super interested in solutions to this problem.

ericgsmith’s picture

On further investigation - I don't think views is smart enough to add all the specific contexts as the issue summary describes, I can only see it adding the full url context here https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/views...