Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in

AliN11 picture AliN11 · Aug 1, 2016 · Viewed 45.4k times · Source

I don't have any problem on localhost. but when i tested my codes on server, end of every page i see this notice.

my code:

<?php
ob_start();
include 'view.php';

$data = ob_get_contents();
ob_end_clean();
include 'master.php';
ob_end_flush();  // Problem is this line

Answer

alexg picture alexg · Jun 19, 2018

WordPress attempts to flush the output buffers on shutdown. It fails because you have already called ob_end_flush().

You should be able to keep compression on, and simply unhook the flush action:

remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );

You can now call ob_end_flush() manually, and keep zlib compression on.