WordPress' Most Abused File

🔗 **Source:** [WordPress' Most Abused File](https://www.linkedin.com/pulse/wordpress-most-abused-file-malcolm-peralty-80pee/)
📄 **Full text:** ![[Full Document Contents/Articles/WordPress' Most Abused File.md|WordPress' Most Abused File by linkedin.com]]
## Highlights
- I've spent a good part of the last twenty years cleaning up after one file. So let me save you some time: admin-ajax.php is the most-abused file in WordPress. ([View Highlight](https://read.readwise.io/read/01kt24j04p4fttgwm5hvck8tkz))
- Note: Thesis: admin-ajax.php is WordPress's most-abused file.
- Tags: atom/literature/h1
- And every single call boots the entire WordPress stack. Core, all your plugins, the theme, wp-admin/includes/admin.php, admin\_init. All of that, often for a response that amounts to { "success": true }. ([View Highlight](https://read.readwise.io/read/01kt24j1peam3xr60e86y310zd))
- Note: Mechanism: every admin-ajax call boots the full WP stack even for a trivial response.
- Tags: atom/literature/h2
- The Heartbeat API. While someone's actively in the post editor, it polls every 15 seconds by default (it backs off to 60 on the dashboard, and it doesn't run on the frontend at all unless a plugin turns it on). Sounds reasonable until you picture a newsroom with 50 editors all sitting in the editor at once. That's 12,000 uncacheable bootstraps an hour, before a single visitor hits the frontend. And plugin authors keep hooking more into it. Session management, post locking, auto-save. Useful, all of it. Just maybe not at 15-second granularity. ([View Highlight](https://read.readwise.io/read/01kt24j4xwx11a77afc6a38x0f))
- Note: Heartbeat abuse: 50 editors = 12,000 uncacheable bootstraps/hour before any visitor.
- Tags: atom/literature/h2
- Live search. Every keystroke is a fresh bootstrap. Doesn't matter that the query resolves in 5 milliseconds. The bootstrap alone can cost 70ms before your handler even runs. ([View Highlight](https://read.readwise.io/read/01kt24j788b1z2gr8b224z7c1y))
- Note: Bootstrap tax: live search pays ~70ms per keystroke even when the query resolves in 5ms.
- Tags: atom/literature/h3
- - Micro-cache your responses. Wrap read-heavy callbacks in get\_transient() / set\_transient(). A 15-second cache on "recent comments" or "popular posts" is plenty fresh. If you've got Redis or Memcached, wp\_cache\_get() / wp\_cache\_set() gets you sub-second lookups that skip the database entirely. ([View Highlight](https://read.readwise.io/read/01kt24j912wps7fjg7n16wyp0n))
- Note: Fix: micro-cache read-heavy callbacks with transients (or object cache) to skip the DB.
- Tags: action/h1