Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Quoting Alex Pott in #2453341-36: Contact forms don't have necessary cache contexts & tags; flood control should work on validate, not on view:
+++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -167,7 +167,7 @@ public function onRespond(FilterResponseEvent $event) { - if ($response->headers->has('X-Drupal-Cache-Tags')) { + if ($response->headers->get('X-Drupal-Cache-Tags')) { @@ -175,7 +175,7 @@ protected function updateDrupalCacheHeaders(Response $response, CacheableInterfa - if ($response->headers->has('X-Drupal-Cache-Contexts')) { + if ($response->headers->get('X-Drupal-Cache-Contexts')) {
I'm not particularly happy happy about the concept of http headers with no value. Something feels really off. Discussed with @Wim Leers in IRC. We decided that we'll open a followup to discuss how to prevent this.
This is that follow-up.
Comments
Comment #1
Wim LeersThe IRC discussion we had:
Comment #2
Fabianx CreditAttribution: Fabianx for Drupal Association commentedI don't actually think we need this if / when we do the header consolidation in the other issue ...
So I would tend to close / dup this ...
Comment #3
Wim LeersOhhhh good point! Can you link to that issue and then close this one?
Comment #4
Fabianx CreditAttribution: Fabianx for Drupal Association commentedClosing as a duplicate of #2463009: Introduce CacheableResponseInterface: consolidate ways of setting X-Drupal-Cache-Tags/Contexts headers, which will make this problem trivial as its just one point of setting the header then.