Caching & performance
The rule the whole plugin is built around: rendering never blocks on a remote API. The only exception is a feed's very first fetch, right after creation.
Stale-while-revalidate
- Fetched items are stored durably in the database (post meta on the feed, not transients — object caches may evict transients, which would break serving stale data).
- On render, whatever is cached is served immediately — fresh or stale. If it's past the feed's TTL (default 1 hour, per-feed setting), a one-off background refresh is scheduled so the next view is fresh.
- A 15-minute cron sweep also prefetches any feed past its TTL, so in practice visitors rarely even trigger the background path.
Failure behavior
- A failed fetch never clobbers cached items — the last good data keeps rendering, indefinitely if need be. The error is recorded and shown in the admin feed list (and to admins in
empty.phpif there's genuinely nothing cached). - Consecutive failures back off exponentially (TTL × 2, ×4, …, capped at 6 hours) so a dead endpoint isn't hammered.
- A per-feed lock prevents fetch stampedes when cron and page loads overlap.
Image localization
Feed images are downloaded to wp-content/uploads/thewpfeeds/{feed_id}/ during fetch and served from your domain:
- LinkedIn image URLs are signed and expire within days — hotlinking them is broken by design; localization is the fix.
- Files are content-addressed per item, so unchanged posts skip re-downloading; images no longer referenced are pruned on each successful fetch; a feed's folder is deleted with the feed.
- If a download fails, templates transparently fall back to the remote URL —
$item->image()always gives you the best available option. - Nothing enters the WordPress media library — no attachment pollution.
Bonus effects: visitors' browsers never talk to LinkedIn/YouTube/Bluesky CDNs (privacy, GDPR posture), and images get your server's caching headers.
Tuning
- Per-feed TTL — feed setting, seconds (minimum 300).
- Item count — per feed, or per render via the block/
thewpfeeds_render()args. - The cron events are standard WP-Cron (
thewpfeeds_refreshsweep + one-off refreshes). On low-traffic sites, wire WP-Cron to a real cron job as usual for punctual refreshes.