magento2: X-Magento-Tags Header too long - Apache / PHP error 500 on category pages
Preconditions (*)
- Latest Magento 2.3.4 (Developer Mode)
- A category containing many (simple) products (in this case about 2600)
- No Varnish
- Apache + PHP7.3-FPM (happens with 7.2 too)
Steps to reproduce (*)
It seems magento creates http headers that are too long for most or some apache configurations. For me it happens when visiting a category page with many products.
PHP error log:
[Fri Feb 21 09:20:55.678915 2020] [proxy_fcgi:error] [pid 13470:tid 140320488904448] [client XXXXX:53641] Premature end of script headers: index.php, referer: https://XXXXX/shop/catalog/category/view/id/3
[Fri Feb 21 09:20:55.678978 2020] [proxy_fcgi:error] [pid 13470:tid 140320488904448] [client XXXXX:53641] AH01070: Error parsing script headers, referer: https://XXXXX/shop/catalog/category/view/id/3
[Fri Feb 21 09:20:55.678984 2020] [proxy_fcgi:error] [pid 13470:tid 140320488904448] (22)Invalid argument: [client XXXXX:53641] AH01075: Error dispatching request to : , referer: https://XXXXX...
Expected result (*)
I can understand that these headers are important for caching, and the HTTP spec doesnt define a limit for header sizes. But most servers do in fact implement a limit (around ~8k), so i think this is a bug that should be fixed. https://stackoverflow.com/questions/686217/maximum-on-http-header-values
Actual result (*)
In my specific case, the http response is cached by magento FPC, and returned to the client in:
magento/vendor/magento/framework/App/Http.php:122
The X-Magento-Tags heade size is 27kB. The content is made up of strings like this one: cat_p_2611,cat_p,cat_p_2584,cat_p_2585
.
If i add the following in the row after, the page works again:
$this->_response->setHeader('X-Magento-Tags', "test");
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 31 (16 by maintainers)
This is strongly related to https://github.com/magento/magento2/issues/6401 and is probably a duplicate. But I’ll leave this ticket open for now, since it needs to be more in the spotlight and needs to get fixed sooner rather than later.
We have noticed that this issue has not been updated for 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.
I do some logging and found a very large ‘X-Magento-Tags’ header entry:
I edited my comment because I accidentally copied the wrong line 😦
@ihor-sviziev It´s only a workaround! But after all, better than a 503!
My workaround:
vendor/magento/framework/App/Http.php