Caching

1.5.1 (Sep 30, 2019) — Download from your account page

Make FacetWP-powered pages load quicker with page caching.

Installation

Simply activate the plugin. Starting in version 1.5.0, plugin will automatically symlink db.php into the /wp-content/ folder.

Setting the expiration

By default, the cache will expire after 1 hour (3600 seconds). You can adjust the expiration with the following filter:

function my_cache_lifetime( $seconds ) {
    return 86400; // one day
}
add_filter( 'facetwp_cache_lifetime', 'my_cache_lifetime' );

Page-specific expiration

You can also set custom expirations for specific pages:

function my_cache_lifetime( $seconds, $params ) {
    if ( 'products' == $params['uri'] ) { // http://website.com/products/
        $seconds = 1800;
    }
    return $seconds;
}
add_filter( 'facetwp_cache_lifetime', 'my_cache_lifetime', 10, 2 );

Clearing the cache

When logged in and viewing your front-facing page, you’ll see a FWP menu in the black admin bar.

clearing the cache

Clearing the cache (via code)

FWP_Cache()->cleanup(); // clear expired cache

FWP_Cache()->cleanup( 'all' ); // clear everything

FWP_Cache()->cleanup( 'demo/cars' ); // clear the "/demo/cars/" page

Changelog

1.5.1

  • Improved switched to wp_schedule_single_event for better cron handling

1.5.0

  • Improved automatically symlink db.php
  • Improved automatically clear the cache on deactivation

1.4.1

  • Improved support multisite (props Mark Chouinard)