Compression is a simple way to speed up the site. PHP’s gzip compression is excellent. And using it is very convenient:
Simply put these codes before any HTML content at the beginning of the PHP script:
<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
In WordPress, the suitable position for these codes is the beginning of the header.php file of the theme.