B2B E-commerce / Performance Engineering

ACF Flexible Filters

Redis-Cached Product Filtering at Scale

Muhammad Afaque·Solo plugin developer·2 months
<200ms
Response Time
~2s
Before
95%+
Cache Hit Rate
WP Transients
Fallback

Overview

ACF Flexible Filters is a WordPress plugin that adds Redis-cached, AJAX-powered product filtering for sites using ACF Flexible Content fields. Built to handle 9,500+ SKUs in the HydraSearch Ecosystem, it degrades gracefully on hosts without Redis by falling back to WP Transients.

Problem

Filtering 9,500+ SKUs by spec attributes stored in ACF Flexible Content fields is expensive. Each filter combination is effectively a custom query against unstructured meta fields, and doing this live for every visitor doesn't scale.

The core issue is that ACF Flexible Content stores data in a nested serialized format in wp_postmeta, making direct SQL queries for filtering both slow and unreliable. Standard WordPress meta queries can't efficiently search within serialized data.

Approach

Built a caching layer in front of the filter queries with Redis as primary store and WP Transients as automatic fallback. Cache keys are scoped per taxonomy term and invalidated via pattern matching automatically whenever a product or collection is saved.

The plugin hooks into WordPress's save_post action to detect when products or collections change, then invalidates only the affected cache keys rather than flushing the entire cache.

Architecture

Caching Strategy

Redis serves as the primary cache store with WP Transients as automatic fallback. Cache keys follow the pattern acf_filter_sidebar_{term_id}, ensuring isolated invalidation when individual taxonomy terms change.

Cache Invalidation

Pattern-based invalidation (acf_filter_result_*) triggers automatically on product/collection save via WordPress hooks. When a product is updated, only cache keys matching that product's taxonomy terms are invalidated, not the entire filter cache.

Graceful Degradation

When Redis isn't available, the plugin automatically falls back to WP Transients. No configuration needed, no breakage on shared hosts. The API surface remains identical regardless of which backend is active.

AJAX Interface

Filter requests are handled via AJAX with debounced input to prevent server flooding. Results update in real-time as users select filter options, with smooth transitions between filter states.

Results

  • Cut filter/search response time from ~2s to sub-200ms in production
  • Architecture is portable to any ACF Flexible Content setup, not just this one client's catalog structure
  • Graceful degradation: works with or without Redis installed
  • Zero configuration required -- auto-detects Redis availability

Quick Info

Client
Internal tool, built for and proven on the HydraSearch Ecosystem
Role
Solo plugin developer
Duration
2 months

Tech Stack

PHP ACF Pro Redis AJAX WordPress WP Transients