Skip to content
Skip to the article
In WordPress: 10 articles
WordPress

Docket Cache baseline configuration

Avunu's wp-config.php baseline for the Docket Cache file-based object cache, with what each constant changes and which ones to leave out.

Updated
Applies to
  • WordPress 6.x
  • Docket Cache 26.x
Tags
  • wordpress
  • caching
  • performance
  • wp-config
Reading time
5 min

Docket Cache is a persistent object cache that stores cached objects as PHP files, so OPcache serves them from memory. Use it on hosts that don't offer Redis or Memcached. This page lists the constants Avunu sets in wp-config.php and why.

Constants in wp-config.php override the plugin's Configuration screen and lock those options in the admin, so the settings survive a database reset or a migration.

Note

Only one persistent object cache can be active, because they all use the same wp-content/object-cache.php drop-in. Don't run Docket Cache alongside Redis Object Cache or a host's built-in object cache. See wp-config Reference for the Redis alternative.

Baseline

Add this to wp-config.php above the /* That's all, stop editing! */ line:

// Docket Cache: storage limits.
define( 'DOCKET_CACHE_MAXFILE', 200000 );          // Default 50000.
define( 'DOCKET_CACHE_MAXSIZE_DISK', 2147483648 ); // 2 GB. Default 500 MB.
define( 'DOCKET_CACHE_CHUNKCACHEDIR', true );      // Spread files across subfolders.
define( 'DOCKET_CACHE_FLUSH_STALECACHE', true );

// Docket Cache: caching features.
define( 'DOCKET_CACHE_PRECACHE', true );
define( 'DOCKET_CACHE_MENUCACHE', true );
define( 'DOCKET_CACHE_MOCACHE', true );
define( 'DOCKET_CACHE_OPTERMCOUNT', true );
define( 'DOCKET_CACHE_OPTWPQUERY', true );
define( 'DOCKET_CACHE_MISC_TWEAKS', true );
define( 'DOCKET_CACHE_WOOTWEAKS', true );
define( 'DOCKET_CACHE_POSTMISSEDSCHEDULE', true );
define( 'DOCKET_CACHE_WPOPTALOAD', false );

// Docket Cache: trim WordPress features the site doesn't use.
define( 'DOCKET_CACHE_HEADERJUNK', true );
define( 'DOCKET_CACHE_WPEMOJI', true );
define( 'DOCKET_CACHE_WPDASHBOARDNEWS', true );
define( 'DOCKET_CACHE_WPBROWSEHAPPY', true );
define( 'DOCKET_CACHE_WPSERVEHAPPY', true );
define( 'DOCKET_CACHE_WPLAZYLOAD', false );        // Keep native lazy loading.

// Docket Cache: admin and maintenance.
define( 'DOCKET_CACHE_PAGELOADER', false );
define( 'DOCKET_CACHE_PRELOAD', true );
define( 'DOCKET_CACHE_GCACTION', true );
define( 'DOCKET_CACHE_FLUSHACTION', true );
define( 'DOCKET_CACHE_OPCSHUTDOWN', true );
define( 'DOCKET_CACHE_CRONOPTMZDB', 'weekly' );
define( 'DOCKET_CACHE_CRONBOT', false );
define( 'DOCKET_CACHE_STATS', false );
define( 'DOCKET_CACHE_LOG', false );
define( 'DOCKET_CACHE_LOG_ALL', false );
define( 'DOCKET_CACHE_SIGNATURE', false );
define( 'DOCKET_CACHE_CHECKVERSION', false );
define( 'DOCKET_CACHE_AUTOUPDATE', false );

What the Settings Do

Storage Limits

ConstantValueWhy
DOCKET_CACHE_MAXFILE200000Maximum number of cache files. The default of 50,000 fills up quickly on WooCommerce sites, and the cache churns when it hits the limit.
DOCKET_CACHE_MAXSIZE_DISK2147483648Total cache size on disk (2 GB). Check the account's disk and inode quota before raising it.
DOCKET_CACHE_CHUNKCACHEDIRtrueSplits files into subfolders so one directory doesn't hold hundreds of thousands of files. Makes manual clearing and backups much faster.
DOCKET_CACHE_FLUSH_STALECACHEtrueRemoves stale WooCommerce and WordPress query caches instead of waiting for them to expire.

Caching Features

ConstantValueWhy
DOCKET_CACHE_PRECACHEtrueLoads the objects a URL needed last time in one go, before WordPress asks for them.
DOCKET_CACHE_MENUCACHEtrueCaches rendered navigation menus. Off by default.
DOCKET_CACHE_MOCACHEtrueCaches translation files. Worth it on any site not in English, and harmless otherwise.
DOCKET_CACHE_OPTERMCOUNT / OPTWPQUERYtrueOptimize term-count and core query patterns.
DOCKET_CACHE_MISC_TWEAKS / WOOTWEAKStrueGeneral WordPress and WooCommerce performance tweaks (both default to on).
DOCKET_CACHE_POSTMISSEDSCHEDULEtruePublishes scheduled posts that WP-Cron missed.
DOCKET_CACHE_WPOPTALOADfalseLeaves option autoloading alone. Fix large autoloaded options directly instead (see Database Optimization Queries).

Trimmed Features

Each of these turns a WordPress feature off when set to true.

ConstantEffect
DOCKET_CACHE_HEADERJUNKRemoves generator tags, RSD/WLW links, and similar clutter from <head>.
DOCKET_CACHE_WPEMOJIRemoves the emoji detection script and styles.
DOCKET_CACHE_WPDASHBOARDNEWSRemoves the Events and News dashboard widget and its remote requests.
DOCKET_CACHE_WPBROWSEHAPPY / WPSERVEHAPPYStops the browser and PHP version checks that call WordPress.org from the admin.
DOCKET_CACHE_WPLAZYLOADSet to false so native image lazy loading stays on.

These remove features that some sites rely on. Enable them per site only when you're sure:

ConstantTurns offLeave it off when
DOCKET_CACHE_WPFEEDRSS/Atom feedsThe site has a blog, podcast, or feed-driven integration.
DOCKET_CACHE_WPSITEMAPCore wp-sitemap.xmlNo SEO plugin provides its own sitemap.
DOCKET_CACHE_PINGBACKXML-RPC and pingbacksJetpack, the mobile app, or another service uses XML-RPC.
DOCKET_CACHE_WPAPPPASSWORDApplication PasswordsAny integration authenticates to the REST API with an application password.
DOCKET_CACHE_LIMITHTTPREQUESTMost outgoing HTTP requests from plugins on admin pagesPremium plugins need license checks or update requests. Use DOCKET_CACHE_LIMITHTTPREQUEST_WHITELIST for hosts that must get through.

Admin and Maintenance

ConstantValueWhy
DOCKET_CACHE_PAGELOADERfalseTurns off the admin page-loading overlay.
DOCKET_CACHE_PRELOADtrueWarms common admin pages after a cache flush.
DOCKET_CACHE_GCACTION / FLUSHACTIONtrueAdds Garbage Collector and extra Flush buttons to the plugin screens.
DOCKET_CACHE_OPCSHUTDOWNtrueAlso flushes OPcache when the plugin is deactivated.
DOCKET_CACHE_CRONOPTMZDB'weekly'Runs OPTIMIZE TABLE on the WordPress tables weekly. Use 'never' on very large databases and optimize during a maintenance window.
DOCKET_CACHE_CRONBOTfalseCronbot is an external service that pings the site hourly. Use a real server cron instead (see WordPress Cron).
DOCKET_CACHE_STATS / LOG / LOG_ALLfalseAvoids the overhead of stats and logging in production. Turn LOG on temporarily when troubleshooting.
DOCKET_CACHE_SIGNATUREfalseRemoves the Docket Cache HTML comment and response header.
DOCKET_CACHE_CHECKVERSIONfalseSkips the plugin's critical-version check.
DOCKET_CACHE_AUTOUPDATEfalseUpdates come through Avunu's normal update process instead of WordPress auto-updates. If nobody updates the site regularly, leave auto-updates on.

Settings Left Out

Older copies of this baseline included constants that no longer do anything on current WordPress:

  • DOCKET_CACHE_ADVCPOST and the related post-type constants: Advanced Post Cache only runs on WordPress 6.1 and older, because core now caches WP_Query results itself.

  • DOCKET_CACHE_RTIMAGEOVERWRITE: an internal runtime option that the plugin sets for itself. To keep only one copy of edited images, define WordPress's own IMAGE_EDIT_OVERWRITE constant instead.

Useful Commands

From the WordPress directory:

wp cache flush        # Flush the object cache.
wp cache run:gc       # Run Docket Cache's garbage collector now.
wp cache status       # Show the drop-in status.

Sources

This article is in the public domain (CC0 1.0), code samples included. Use it however helps you.