How to set Browser caching to speed up your website without plugin


// Browser caching
if (!function_exists('custom_browser_caching')) {
    function custom_browser_caching()
    {
        $expires = 31536000; // 1 year
        header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expires) . " GMT");
        header("Cache-Control: max-age=" . $expires . ", public");
    }
    add_action('send_headers', 'custom_browser_caching');
}

Leave a Comment

Your email address will not be published. Required fields are marked *