cache_javascript_headers

The timeline below displays how wordpress function cache_javascript_headers has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Sets the HTTP headers for caching for 10 days with JavaScript content type.
 *
 * @since 2.1.0
 */
function cache_javascript_headers()
{
    $expires_offset = 10 * DAY_IN_SECONDS;
    header('Content-Type: text/javascript; charset=' . get_bloginfo('charset'));
    header('Vary: Accept-Encoding');
    // Handle proxies.
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires_offset) . ' GMT');
}

WordPress Version: 6.3

/**
 * Sets the HTTP headers for caching for 10 days with JavaScript content type.
 *
 * @since 2.1.0
 */
function cache_javascript_headers()
{
    $expiresOffset = 10 * DAY_IN_SECONDS;
    header('Content-Type: text/javascript; charset=' . get_bloginfo('charset'));
    header('Vary: Accept-Encoding');
    // Handle proxies.
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expiresOffset) . ' GMT');
}

WordPress Version: 6.1

/**
 * Sets the headers for caching for 10 days with JavaScript content type.
 *
 * @since 2.1.0
 */
function cache_javascript_headers()
{
    $expiresOffset = 10 * DAY_IN_SECONDS;
    header('Content-Type: text/javascript; charset=' . get_bloginfo('charset'));
    header('Vary: Accept-Encoding');
    // Handle proxies.
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expiresOffset) . ' GMT');
}

WordPress Version: 5.4

/**
 * Set the headers for caching for 10 days with JavaScript content type.
 *
 * @since 2.1.0
 */
function cache_javascript_headers()
{
    $expiresOffset = 10 * DAY_IN_SECONDS;
    header('Content-Type: text/javascript; charset=' . get_bloginfo('charset'));
    header('Vary: Accept-Encoding');
    // Handle proxies.
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expiresOffset) . ' GMT');
}

WordPress Version: 5.1

/**
 * Set the headers for caching for 10 days with JavaScript content type.
 *
 * @since 2.1.0
 */
function cache_javascript_headers()
{
    $expiresOffset = 10 * DAY_IN_SECONDS;
    header('Content-Type: text/javascript; charset=' . get_bloginfo('charset'));
    header('Vary: Accept-Encoding');
    // Handle proxies
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expiresOffset) . ' GMT');
}

WordPress Version: 3.7

/**
 * Set the headers for caching for 10 days with JavaScript content type.
 *
 * @since 2.1.0
 */
function cache_javascript_headers()
{
    $expiresOffset = 10 * DAY_IN_SECONDS;
    header("Content-Type: text/javascript; charset=" . get_bloginfo('charset'));
    header("Vary: Accept-Encoding");
    // Handle proxies
    header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT");
}