- Issue created by @ioannis.cherouvim
I use apache2 with FPM. Unfortunately mod_proxy_fcgi has a hardcoded limit of 8192 bytes per http response header. Thus, when my Drupal 9/10 website emits this 10KB http response header on some pages:
Surrogate-Key: zMsic1b dsiuGM5 KRjdeih 1gd6dI1... (10KB total)
then these pages immediately throw an error 500 and the following is logged on apache:
[Tue Jan 23 12:11:44.467158 2024] [proxy_fcgi:error] [pid 1248914:tid 140134414530112] [client 127.0.0.1:0] Premature end of script headers: index.php
[Tue Jan 23 12:11:44.467305 2024] [proxy_fcgi:error] [pid 1248914:tid 140134414530112] [client 127.0.0.1:0] AH01070: Error parsing script headers
[Tue Jan 23 12:11:44.467315 2024] [proxy_fcgi:error] [pid 1248914:tid 140134414530112] (22)Invalid argument: [client 127.0.0.1:0] AH01075: Error dispatching request to :
The key phrase here is "Premature end of script headers".
Blog post which explains the issue:
- https://maxchadwick.xyz/blog/http-response-header-size-limit-with-mod-pr...
Apache mod_proxy_fcgi bug:
- https://bz.apache.org/bugzilla/show_bug.cgi?id=64919
This can be mitigated by setting a lower "Cache tag hash length", to have those pages render the Surrogate-Key header to just under 8KB. But this is not future proof, because other complex pages may later on appear on the site which will exceed the 8KB.
Thus I did the following in `src/EventSubscriber/SurrogateKeyGenerator.php` to solve the issue:
- $response->headers->set('Surrogate-Key', $surrogate_key_header_value);
+ $response->headers->set('Surrogate-Key', substr($surrogate_key_header_value, 0, 8174));
This of course will remove some tags (anything that exceeds 8192) which may cause other issues on the cache invalidation.
So, please consider documenting this somehow on the module or incorporating that hack, until apache2 mod_proxy is fixed to support a configurable buffer size.
Active
3.14
Code