Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291420

"Taxonomy term ID from URL" default views argument should have route as cache context, not url

$
0
0

Problem/Motivation

I have a low Varnish hit ratio on a website, and I'm wondering if it could be due to the fact that many annoying bots may request some pages with dummy URL GET query parameters that would prevent cache hits (in Drupal then in Varnish).
Thanks to the Redis module, I found out some "Render cache entries with most variations" related to views using the "Taxonomy term ID from URL" default argument.
This sets a cache context 'url' on the rendered view. I might be wrong, but I guess this default arg only depends on the path part of the URL (/myterms/42), not on the query args (?foo=bar).
If so, the cache context should be 'url.path' and not 'url', so that requests to /myterms/42, /myterms/42?foo=bar, /myterms/42?baz,...) all hit the same cache entry.

I saw that this code was set in https://git.drupalcode.org/project/drupal/-/commit/d2f9c183bf26e1c, but I could not find any explanation about this in #2318377: Determine whether a view is cacheable and its required contexts, store this i/t config entity, so I guess it's just a mistake.

Proposed resolution

This is a quite simple change, just replace 'url' with 'url.path' in web/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php

Remaining tasks

Ensure 'url.path' is enough, ensure 'url' is not needed.
Maybe search for other mistakes of that kind in other default arg plugins.

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.


Viewing all articles
Browse latest Browse all 291420

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>