/', '', $html); // Remove whitespace between tags $html = preg_replace('/>\s+<', $html); // Collapse multiple spaces $html = preg_replace('/\s{2,}/', ' ', $html); // Trim spaces around HTML return trim($html); } Public function aabcore_cache_he_cache( $file, $Maxage, $filemtime ){ $mtime = $filemtime; // last modified timestamp $size = filesize($file); // file size $mime = mime_content_type($file); // optional content-type // --- Derived values --- $lastModified = gmdate("D, d M Y H:i:s", $mtime) . " GMT"; $expires = gmdate("D, d M Y H:i:s", time() + $Maxage) . " GMT"; // Strong ETag: based on file modification time + size $etag = '"' . md5($mtime . $size) . '"'; // --- Send headers --- header("Content-Type: ".$mime); header("Last-Modified: ".$lastModified); header("ETag: ".$etag); header("Expires: ".$expires); //header("Cache-Control: public, max-age= ".$Maxage); $n_cache_am_cache = get_option( 'aabc_cache_a_cache'); $n_cache_an_cache = get_option( 'aabc_cache_b_cache'); $n_cache_ao_cache = get_option( 'aabc_cache_c_cache'); $n_cache_ap_cache = get_option( 'aabc_cache_d_cache'); header("Cache-Control:".$n_cache_am_cache.' '.$n_cache_an_cache.' '.$n_cache_ao_cache.' '.$n_cache_ap_cache); // --- Handle conditional request (returns 304 if unchanged) --- $clientEtag = sanitize_text_field( wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ?? null)); $clientLastModified =sanitize_text_field( wp_unslash( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ?? null)); if ( ($clientEtag && trim($clientEtag) === $etag) || ($clientLastModified && $clientLastModified === $lastModified) ) { header("HTTP/1.1 304 Not Modified"); exit; } } }new Aabcore_cache_on_cache();