Caching

1.6.1 (Sep 2, 2021) — 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.6.1

  • Fixed when clearing cache within `wp-admin`, preserve existing query args on redirect

1.6

  • Fixed require FacetWP 3.8 (cache raw JSON requests)

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)