i was scratching my head last Friday trying to figure out why a piece of working code in dev returns me encoded html instead of json while in production behide reverse proxy.
i was kind of knowing which direction to go, luckily i found this thread posted almost 2 years ago and it helps!!
i simply add line in my controller action, before render json reponse
mtHeader::json();
and it works for me like a charm, btw a bit change in mtHeader.php around lines: 270
if (isset(Yii::app()->cache)) // added line
~~~
if (is_array(self::$_mimeTypes) && isset(Yii::app()->cache)) { //modified line
so i am sharing it here and thanks to this thread.