Newly Published Post Missing From Homepage/Sidebar Even Though the Database Says "Published": Stale Route Cache After a Direct DB Insert

TL;DR — Posts inserted directly into the database via a script (bypassing the admin API) were correctly status: "published" in every query, but the homepage feed, category listing, and sidebar kept showing the pre-insert state. The per-URL route cache is only invalidated by the admin API's own update handler calling cache.invalidate({ tags }) — a direct DB write never triggers that.
Table of Contents
Symptom
SELECT slug, status FROM ec_posts WHERE slug = 'new-post-slug';
-- status: published (confirmed correct)...yet the live homepage doesn't show it, and neither does the category page it should appear under.
Root cause
Cache invalidation for cached listing pages is a side effect of the admin API's content-update route handler, not something the data layer triggers automatically on any write to the table. A script that inserts rows straight into Postgres, skipping that API route entirely, never fires the invalidation — so the previously-cached page just keeps serving its stale snapshot until the cache entry's TTL expires or the app process restarts.
Fix
There's no remote cache-clear available from a content script. Either wait out the TTL, or restart the app process if you have that access. This is expected behavior given how the cache is wired — not a bug to patch inside the insert script itself.
Lessons learned
- Flag this to whoever owns deploy/process access before running a batch of direct-DB content inserts on a live, cached site — set the expectation up front rather than chasing it as an application bug.
- Query the database directly to confirm real state before assuming a rendering bug — cache staleness produces a DB state that's actually correct while the rendered page is wrong.




Comments