Every database query in WP SSR Framework — whether in a web controller, an API controller, or a view composer — can be wrapped in a single caching primitive:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Ahondev/portfolio-v2/llms.txt
Use this file to discover all available pages before exploring further.
Base::remember(). This method stores the result of any callback in a WordPress transient for a configurable TTL, short-circuiting repeated queries on subsequent requests. Alongside it, CacheServiceProvider adds a prominent ”🧹 Vider le cache” button to the WP admin bar, giving administrators a one-click escape hatch whenever stale data appears after a deployment or bulk content update.
Base::remember() — The Core Caching Primitive
remember() is defined on the Base class, which all controllers and composers extend. It wraps WordPress’s native transient API in a thin, readable interface.
| Parameter | Type | Description |
|---|---|---|
$key | string | Unique transient key. Use a versioned suffix (e.g. _v1) to bust the cache on deploys. |
$ttl | int | Time-to-live in seconds. Pass 0 for no expiry. |
$callback | callable | The expensive operation whose result should be cached. |
get_transient() returns the stored value and the callback is never invoked. On a cache miss (first call, or after expiry), the callback runs, its return value is stored, and that value is returned.
WordPress
get_transient() returns false both when the key doesn’t exist and when it has expired. Do not store the literal boolean false as a cached value — it will always be treated as a miss.Real-World Examples
BothAppComposer and HomeController cache the same service query with a 5-minute TTL (300 seconds). They intentionally share the key composer_services_v1 so the result is computed once and reused across both the global composer and the home page controller.
- AppComposer
- HomeController
AppComposer::compose() runs for every view (views() returns ['*']). Caching here prevents the Service::query()->all() call from firing on every single page load.Admin Bar Cache Flush
CacheServiceProvider::boot() adds a ”🧹 Vider le cache” node to the WordPress admin bar, visible only to users with the manage_options capability.
admin-post handler that:
Verify permissions and nonce
The handler checks
current_user_can('manage_options') and validates the flush_cache_action nonce. An invalid request is rejected with a 403 response.Delete all transients from the database
Two raw
$wpdb queries remove every transient and its timeout option row:Flush the object cache
If an external object cache (Redis, Memcached) is active,
wp_cache_flush() is called to purge it as well.When to Flush the Cache
| Situation | Action |
|---|---|
| Deploying new code that changes query results or data shapes | Flush immediately after deployment |
| Bulk updating or importing posts | Flush after the import completes |
| Stale data appearing on the frontend | Flush from the admin bar |
| Changing ACF field values that are cached | Flush, or lower the TTL for that query |
| After clearing the SSG static file cache | Consider flushing transients too for consistency |
Related Pages
Rate Limiting
Rate-limit counters are stored as transients — understand the interaction before flushing in production.
Static Site Generation
SSG stores pre-rendered HTML on disk, separate from the transient cache — learn how the two layers complement each other.