Enh #2819 - Mitigate BREACH attack possibilities

This is a fix for #2819 and is mostly a of backport of https://github.com/yiisoft/yii2/issues/1634