/* ===== TNB CACHE SERVE 2026-11-05: отдача HTML из кэша (ранняя) ===== */
if ( ! defined( 'WP_ADMIN' ) && ! defined( 'DOING_AJAX' ) && ! defined( 'DOING_CRON' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
$_tnb_uri = isset( $_SERVER['REQUEST_URI'] ) ? strtok( $_SERVER['REQUEST_URI'], '?' ) : '/';
$_tnb_file = WP_CONTENT_DIR . '/tnb-cache/' . md5( 'https://tenebro.ru' . $_tnb_uri ) . '.html.gz';
if ( ! is_user_logged_in() && file_exists( $_tnb_file ) && ( time() - filemtime( $_tnb_file ) ) < 21600 ) {
$_tnb_is_gb = strpos( $_SERVER['HTTP_ACCEPT_ENCODING'] ?? '', 'gzip' ) !== false;
header( 'Content-Type: text/html; charset=UTF-8' );
header( 'X-Tenebro-Cache: HIT' );
header( 'Cache-Control: public, max-age=600' );
if ( $_tnb_is_gb ) {
header( 'Content-Encoding: gzip' );
readfile( $_tnb_file );
} else {
readgzfile( $_tnb_file );
}
exit;
}
}
/* ===== TNB CACHE SERVE end ===== */