Caching
Herodotus includes a built-in caching system for optimal frontend performance.
How It Works
- When
[herodotus]runs for the first time on a given day, it queries the database for matching events. - The result is stored as a WordPress transient.
- Subsequent page loads serve the cached result without repeating the same event query.
- The cache expires based on the configured lifetime (TTL).
Cache Key Structure
Query cache keys include parameters, the selected day/month, locale, plugin version and a plugin-specific invalidation generation. A change rotates that generation, so old query, random-pool and related-event entries are no longer reused, including when an object cache still holds an older transient value.
Different languages and attribute combinations keep separate cache entries. This invalidation does not purge full-page or CDN caches.
Cache Invalidation
The cache is automatically cleared when:
- A Herodotus post is created, updated, or deleted.
- The plugin settings are saved.
You do NOT need to manually clear the cache under normal usage.
Configuring Cache TTL
Go to Herodotus - On This Day → Settings → Advanced.
| Value | Meaning |
|---|---|
0 |
Caching disabled (every page load queries the DB) |
3600 |
1 hour (default) |
86400 |
24 hours |
43200 |
12 hours |
Recommendations:
- Development/Testing: Set to
0 - Production (low traffic):
3600-86400 - Production (high traffic):
3600
Compatibility with Page-Level Caching Plugins
Herodotus works alongside:
- WP Super Cache
- W3 Total Cache
- LiteSpeed Cache
- WP Rocket
- Any other full-page caching plugin
Important Note
Full-page caching plugins cache the entire HTML output
of a page. If the page with [herodotus] is cached at the
page level, the events shown may become stale after midnight
(when "today" changes).
Solutions:
- Exclude pages containing
[herodotus]from full-page cache. - Use a page-cache TTL appropriate to how much stale content you can accept. A TTL shorter than 24 hours alone does not guarantee a midnight refresh.
- Schedule a cache purge at midnight in your timezone.
Clear Cache Now
Open Herodotus - On This Day → Settings → Advanced and click Clear Cache Now. This clears Herodotus transients, not your full-page cache, CDN cache or browser cache. Purge those separately after content or plugin updates.
Random and Related Events
Random selection caches the eligible pool, not a fixed random pick. A new pick is made during each uncached render, while full-page caching can freeze the result. Related-event lists also use cached query results. Identical shortcode queries can share a transient.
Midnight and Timezones
The main query cache key includes the selected day and month, locale, parameters and plugin version, so a new calendar date selects a different query cache entry. A full-page cache can prevent WordPress and the plugin from running at all. For an exact daily rollover, exclude event pages from full-page caching or purge them at midnight in the WordPress timezone.
