Built-in Flags

MilliCache automatically assigns flags based on the type of page being cached. These built-in flags cover common WordPress content types.

Homepage Flags#Copied!

Flag Applied When
home Front page or blog index

The home flag is added to:

  • The site's front page (whether static or showing latest posts)
  • The blog posts page (if using a static front page)

Singular Content Flags#Copied!

Flag Format Applied When Example
post:{id} Single post/page/CPT post:123

Every singular page (posts, pages, custom post types) receives a flag with its post-ID. This enables precise invalidation when that specific content is updated.

Archive Flags#Copied!

Archives receive flags based on their type:

Post-Type Archives#Copied!

Flag Format Applied When Example
archive:post Blog/post archive archive:post
archive:{post_type} Custom post type archive archive:product

Taxonomy Archives#Copied!

Flag Format Applied When Example
archive:category:{id} Category archive archive:category:5
archive:post_tag:{id} Tag archive archive:post_tag:12
archive:{taxonomy}:{id} Custom taxonomy archive archive:genre:8

Author Archives#Copied!

Flag Format Applied When Example
archive:author:{id} Author archive archive:author:1

Date Archives#Copied!

Flag Format Applied When Example
archive:{year} Year archive archive:2026
archive:{year}:{month} Month archive archive:2026:01
archive:{year}:{month}:{day} Day archive archive:2026:01:15

Feed Flags#Copied!

Flag Applied When
feed RSS/Atom feed pages

Flag Prefixes in Multisite#Copied!

In multisite installations, flags are automatically prefixed to ensure cache isolation between sites:

Environment Format Example
Single site {flag} post:123
Multisite {site_id}:{flag} 2:post:123
Multi-network {network_id}:{site_id}:{flag} 1:2:post:123

This ensures Site A's post:123 doesn't conflict with Site B's post:123.

Working with Prefixes#Copied!

Use the helper function to handle prefixes correctly:

 1// Prefix flags with the current site's prefix
 2$prefix = millicache_get_flag_prefix( ['home', 'post:123'] );
 3// Returns: ['home', 'post:123'] (single site), ['2:home', '2:post:123'] (multisite), or ['1:2:home', '1:2:post:123'] (multi-network)
 4
 5// Prefix flags for a specific site
 6$flags = millicache_prefix_flags( ['home', 'post:123'], $site_id = 2 );
 7// Returns: ['2:home', '2:post:123'] in multisite

Viewing Assigned Flags#Copied!

Debug Headers#Copied!

Enable debug mode in the Settings UI or via constant to see flags in response headers:

 1define( 'MC_CACHE_DEBUG', true );

Then check the X-MilliCache-Flags header:

X-MilliCache-Flags: home,post:1,post:2,post:3
Tip: Use the MilliCache browser extension for easy flag inspection: Get the MilliCache Browser Extension

WP-CLI#Copied!

 1# View stats for entries with a specific flag
 2wp millicache stats --flag="post:*"
 3
 4# View all entries with the home flag
 5wp millicache stats --flag="home"

Automatic Cache Clearing#Copied!

When content changes, MilliCache automatically identifies and clears related cache entries:

Event Flags Cleared
Post published/updated post:{id}, home, related archives
Post deleted post:{id}, home, related archives
Category updated archive:category:{id}
Site option changed All site cache (configurable)

Use the millicache_flags_related_to_post filter to customize which flags are cleared when a post changes:

 1add_filter( 'millicache_flags_related_to_post', function( $flags, $post ) {
 2    // Also clear featured products when a product is updated
 3    if ( $post->post_type === 'product' && get_post_meta( $post->ID, 'featured', true ) ) {
 4        $flags[] = 'featured';
 5    }
 6    return $flags;
 7}, 10, 2 );

Next Steps#Copied!