• Hello.
    I’m one of the developers behind SecuPress.

    When we block a request we define the constant DONOTCACHEPAGE to prevent cache plugins to store our message.
    But I see you use it only for WordFence:

    // for Wordfence: not to cache 503 pages
    if(defined('DONOTCACHEPAGE') && $this->isPluginActive('wordfence/wordfence.php')){
        if(function_exists("http_response_code") && http_response_code() == 503){
            return $buffer."<!-- DONOTCACHEPAGE is defined as TRUE -->";
        }
    }

    Our customers obviously face the “blocked” message, which was previously cached. Could you simply use this constant for everyone?

    // For plugins that ask not to cache the current page.
    if ( defined( 'DONOTCACHEPAGE' ) && DONOTCACHEPAGE ) {
        return $buffer . '<!-- DONOTCACHEPAGE is defined as TRUE -->';
    }

    Thank you.
    Greg

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Grégory Viguier

    (@greglone)

    I guess you will prefer something like this:

    $override_donotcachepage = false;
    
    /**
     * Allow to override the DONOTCACHEPAGE behavior.
     * To prevent conflict with some plugins.
     *
     * @param bool $override_donotcachepage True will force the override, the page will be cached.
     */
    $override_donotcachepage = apply_filters( 'wp_fastest_cache_override_donotcachepage', $override_donotcachepage );
    
    // For plugins that ask not to cache the current page.
    if ( defined( 'DONOTCACHEPAGE' ) && DONOTCACHEPAGE && ! $override_donotcachepage ) {
    	return $buffer . '<!-- DONOTCACHEPAGE is defined as TRUE -->';
    }
    Plugin Author Emre Vona

    (@emrevona)

    you are right but I prefer to add as below. What is the name of your plugin?

    if(defined(‘DONOTCACHEPAGE’) && $this->isPluginActive(‘YOUR-PLUGIN’)){

    Thread Starter Grégory Viguier

    (@greglone)

    Hi.
    Sorry for the delay, I didn’t get notified.
    This is our plugin but we also have a Pro version. The plugin basenames are secupress/secupress.php and secupress-pro/secupress-pro.php.
    Thank you.

    PS: we use several HTTP codes, not only 503.

    Plugin Author Emre Vona

    (@emrevona)

    is the following code enough?

    if(defined(‘DONOTCACHEPAGE’) && ($this->isPluginActive(‘secupress/secupress.php’) || $this->isPluginActive(‘secupress-pro/secupress-pro.php’))){
    return $buffer.”<!– DONOTCACHEPAGE is defined as TRUE –>”;
    }

    Thread Starter Grégory Viguier

    (@greglone)

    It seems fine to me.
    The only caveat is if SecuPress and a plugin that defines DONOTCACHEPAGE globally are active at the same time: your cache will never work :/
    That’s why I suggested the filter.

    Thread Starter Grégory Viguier

    (@greglone)

    But anyway, thanks for hearing me out, that’s much appreciated. 🙂

    Plugin Author Emre Vona

    (@emrevona)

    ok

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Doesn’t respect DONOTCACHEPAGE’ is closed to new replies.