Optimizing Performance with API Caching #
Every search page and detail page makes API calls to your shelter management system. On high-traffic sites, this can slow page loads and hit API rate limits. Caching stores responses temporarily so repeat requests are served instantly.
When to Enable Caching #
- High traffic sites: More than a few hundred daily visitors – caching prevents API bottlenecks
- Slow API responses: If pages take more than 2-3 seconds to load, caching helps immediately
- Multiple shortcodes per page: A homepage with carousel + compact = multiple API calls per visit
- Featured/homepage displays: These pages get the most traffic and benefit most from caching
Recommended TTL Settings #
| Cache Type | Recommended TTL | Why |
|---|---|---|
| Search Results | 5 minutes | Balances freshness with performance. New arrivals appear within 5 minutes. |
| Detail Pages | 15 minutes | Individual animal data changes less frequently. Longer cache is safe. |
Configure in admin: General > Performance.
As of version 8.16, the TTL you set is the “fresh” window. For a short period after it expires, PetMatchPro serves the slightly older cached copy instantly while refreshing the data in the background (stale-while-revalidate), so visitors no longer hit a slow live API call at the moment the cache expires. The cache is stored in the plugin’s own database table and does not require Redis or any object cache to work.
Caching + Client-Side Filtering #
The best performance comes from combining API caching with client-side features. When enabled, the initial page load fetches data from cache, and filter/sort interactions happen instantly in the browser without additional API calls:
[pmp-search type="adopt" filter="enable" client="enable"]
Cache Clearing #
If you need fresh data immediately (e.g., after a large intake or data correction), clear the cache in admin: Tools > Cache Management. The cache also refreshes automatically after the TTL expires – the first request past expiry triggers a background refresh while visitors keep seeing instant results. To bypass the cache for a single page load while testing, add ?pmp_nocache=1 to the page URL.
Tips #
- Start with the recommended TTLs and adjust based on your update frequency
- Homepages with carousels benefit most – visitors see instant results on repeat visits
- Cache is per-shortcode, so different pages can have different effective freshness
- If animals appear stale, check Stale Content / Cache Issues for troubleshooting
- API caching requires Junior license or higher
Next Steps #
- Performance & Caching Reference — Full caching configuration details
- Stale Content / Cache Issues — Troubleshooting cached data
- Featuring Animals on Your Homepage — High-traffic pages that benefit from caching