0

EDIT the title of this question was "Does anyone know if Jetpack is caching pages/content" but has been changed following the thread.

I just updated a plugin I made. Among others, it does filter the content of a page using the_content hook.

But I noticed that it does not behaves like it should once I pushed the changes online (some parts of my content are missing).

Once I do disable Jetpack, it works as expected.

Does anyone know if Jetpack is caching pages/content and how to clear that cache ?

I didn't find anything about it online.

Thanks !

1

Does anyone know if Jetpack is caching pages/content

Jetpack does not cache the contents of your posts and pages.

Once I do disable Jetpack, it works as expected.

This seems like a conflict between how your code filters the_content, and the way one of the Jetpack features uses the same filter. I would recommend that you deactivate each Jetpack feature, one at a time, until you find the exact source of the conflict. You can then contact the Jetpack support team via this contact form to let them know about the conflict between the 2 plugins.

  • Ok, thanks ! good advice. I disabled "Publicize connections - Automatically share your posts to social networks" and it now works as expected. Guess there is a bug in Jetpack about that, i'll contact them, thanks. – gordie Jan 23 at 14:07
1

I found out that the bug occurs when Publicize connections is enabled in Jetpack, thanks to the advices of @jeherve.

Indeed, I have a function hooked on the_content and which appends content to a specific page :

add_filter( 'the_content','wpsstm_frontend_wizard_content');

function wpsstm_frontend_wizard_content($content){
    if ( !is_page(MYPAGEID) ) return $content;

    ob_start();
    wpsstm_locate_template( 'frontend-wizard.php', true);
    $wizard = ob_get_clean();
    return $content . $wizard;
}

The template is loaded through wpsstm_locate_template(); which calls the core function load_template():

/*
Locate a template & fallback in plugin's folder
*/
function wpsstm_locate_template( $template_name, $load = false, $require_once = true ) {

    if ( !$located = locate_template( 'wpsstm/' . $template_name ) ) {
        // Template not found in theme's folder, use plugin's template as a fallback
        $located = wpsstm()->plugin_dir . 'templates/' . $template_name;
    }

    if ( $load && ('' != $located) ){
        load_template( $located, $require_once );
    }

    return $located;
}

I fixed my problem by setting $require_once = false when I call wpsstm_locate_template() - and thus load_template():

wpsstm_locate_template( 'frontend-wizard.php', true, false);

I guess that Jetpacks 'runs' my filter before it is really displayed. Thus the file already has been loaded once and won't load again until $require_once is set to false.

I found out how to fix it but anyway, that seems to be a bug within Jetpack; or maybe I should handle this in another way. I'll write them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.