WP Super Cache: Store and serve different versions of the same page

WP Super Cache: Store and serve different versions of the same page

WP Super CacheIf you need to store and serve different versions of the same page, using WP Super Cache, you need to write a special plugin to hook in the supercache_filename_str action.

The method described in this post works using PHP mode cache.

WP Super Cache plugins are different from normal plugins, you could read more about this and how to register it in WordPress here.

Your plugin should have at least a function like this:

function my_filename_filter( $extra_str ) {
    if ( custom_criteria_satisfied() ) {
        $extra_str .= '__some_custom_string';
    }
    return $extra_str;
}

add_cacheaction( 'supercache_filename_str' , 'my_filename_filter' );
if ( function_exists( "apply_filters" ) ) {
    add_filter( 'supercache_filename_str' , 'my_filename_filter' );
}

Depending on the custom_criteria_satisfied() condition, WP Super Cache will store and serve different html files for the same page.

To add more feature, like a switch to let the user enable your plugin, take a look at one of the plugins packaged with WP Super Cache.

I got this info from here.

One thought on “WP Super Cache: Store and serve different versions of the same page

Leave a Reply

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