I just stumbled upon an issue with Cloudflare Purger and created
https://www.drupal.org/project/cloudflare/issues/3482279
🐛
Cache tags / hash collision
Active
for that. I then found this issue and I think both are related to some extent. I was hoping the solution of this issue would apply for the Cloudflare Purger Cache-Tags
case, but I don't think it would work if we're adding numerical suffixes such as "-1", "-2" etc when we have multiple "split" response headers.
For Cloudflare specifically their documentation seems to indicate the solution is to have multiple response headers with the same name but different values.
That seems to be applicable to that header as it might for X-Drupal-Cache-Tags
and X-Drupal-Cache-Contexts
as those adhere to the comma-separated specification for response header values (although the "X-" ones are purely for debugging purposes to my knowledge, while the Cloudflare Purger Cache-Tags
is functional). See:
- https://stackoverflow.com/q/3241326
- https://www.rfc-editor.org/rfc/rfc9110.html#name-field-order (above answer points to a deprecated link, this should be the updated info)
So the question is, if this solution is applicable for any headers, should we allow some to be added multiple times without adding numerical suffixes?
In fact it looks like the service parameter cloudflarepurger.cache_tag_header_limit
was introduced early in the code base but is not currently used. Seems like issue
https://www.drupal.org/project/cloudflare/issues/3197141
🐛
Cache-Tag header limit is incorrect
Needs review
proposed re-purposing that service parameter but was not implemented in favor of
https://www.drupal.org/project/drupal/issues/2844620
🐛
FinishResponseSubscriber: Need warning/error when headers exceed 16k
Needs work
in core.
However #2844620 seems to add an auto-incremental suffix - e.g., "-1", "-2" - to the headers and I don't think that would work with Cloudflare Cache-Tags
. The suggestion in their documentation as liked above is to have multiple headers with different values, presumably with the same header name - i.e., Cache-Tags
.
Please let me know if I missed anything.
Examples of execution with the original logic and logic from #3401335 are attached based on the testing script previously shared.
I think the previous patch still relies on \Symfony\Component\HttpKernel\Event\KernelEvent::isMasterRequest()
which is deprecated as of Symfony 6 and therefore not compatible with Drupal 10 (see
https://www.drupal.org/project/drupal/issues/3209618 →
).
Attaching an updated patch that uses \Symfony\Component\HttpKernel\Event\KernelEvent::isMainRequest()
.
The attached patch should fix this issue.