• cargarm3

    (@cargarm3)


    Hi,

    I am using the wfu_before_frontpage_scripts filter to prevent the plugin from loading on pages other than my specific upload page (ID: 216). Here is the snippet I am using:

    PHP

    add_filter('wfu_before_frontpage_scripts', function($changable_data) {
        global $post;
        if ( isset($post->ID) && $post->ID != "216" ) {
            $changable_data["return_value"] = 0;
        }
        return $changable_data;
    }, 10, 1);
    

    The Problem: While this hook successfully prevents the JS/CSS files from being enqueued in the HTML, the plugin is still sending the Set-Cookie: wp_wpfileupload_... header on the HomePage.

    Impact: Since the server (Nginx + SiteGround CDN) detects a Set-Cookie header, it treats the page as dynamic/private. This results in a “MISS” or bypass of the Edge Cache, significantly increasing the TTFB (Time to First Byte) for my users.

    Question: Is there a specific hook or a way to completely prevent the plugin from initializing its session and sending the Set-Cookie header on pages where the shortcode is not present? I need the Homepage to remain cookie-free to ensure 100% cacheability at the CDN level.

    Thank you for your help!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author nickboss

    (@nickboss)

    Hi, try this hook:

    add_filter('wfu_before_frontpage_scripts', function($changable_data) {
    global $post;
    if ( isset($post->ID) && $post->ID != "216" ) {
    $changable_data["return_value"] = 0;
    }
    return $changable_data;
    }, 10, 1);
    if (!function_exists('wfu_maybe_remove_cookie')) {
    function wfu_maybe_remove_cookie() {
    global $post;
    if ( isset($post->ID) && $post->ID != "216" ) {
    setcookie(
    WPFILEUPLOAD_COOKIE,
    '',
    time() - 3600,
    defined("COOKIEPATH") ? COOKIEPATH : '/',
    defined("COOKIE_DOMAIN") ? COOKIE_DOMAIN : '/',
    false,
    false
    );
    unset($_COOKIE[WPFILEUPLOAD_COOKIE]);
    }
    }
    add_action('wp', 'wfu_maybe_remove_cookie');
    }
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.