I’m trying to post a bug but keep getting rejected for having a link in the post, however I can’t see any links. So I’m posting nothing and may try again a 2nd time.
I already have a solution to the problem, but I can’t communicate it here because of the spam rules.
On my dev PC I have PHP ini setting output_buffering = Off
On production server we have output_buffering=4096
Normal behaviour is that if output_buffering is off, headers are sent prematurely and people get errors when they try to send headers in their code.
If output_buffering is off, this always works. If output_buffering is on (set to 4096) which is recommended for server config, then if the JS file is smaller than about 1000 characters, the header sent to the browser is text/html. I can fix the problem by inflating the size of the JS file with a large comment.
I’ve reproduced this for both PHP 5.5 and 5.6 on Windows, using both WAMP and PHP 5.5 on Windows 7 desktop, and using the Apache Lounge install of apache 2.4 and PHP install from http://windows.php.net/download for PHP 5.6 on Windows 2008R2 server. PHP is installed as an Apache (thread-safe) module.
If I run a simple script (below) to try and demonstrate the problem, there is no problem, so it could be some interaction between Yii2 and PHP etc.