This content originally appeared on Hidde's blog and was authored by Hidde de Vries
Heartbeat API is a thing built into WordPress that sends a POST request every 15 seconds. It allows for interesting functionalities like revision tracking, but can also dramatically slow things down and even block editors from editing content (if your connection is quite slow).
The “Edit” pages in WordPress use the Heartbeat API to detect connection loss. If they detect you’ve lost your connection, your ‘Update’/‘Publish’ button will get disabled until your connection is back.
Why?
“Connection lost” message on slow connections
When I was working on a WordPress site this week, I accessed the internet through my 3G MiFi, and added a VPN for security (the less glamorous side of working remotely). It resulted in seeing the ‘Connection lost’ message all the time. It would usually appear before I could make any changes, and never disappear. In which case it stopped me from editing content.
! The error message
High CPU usage
Others comment that Heartbeat leads to high CPU usage: imagine having multiple instances of WordPress edit pages open in a browser, each sending its own POST requests every 15 seconds.
Turning Heartbeat off
Only when I just turned the whole thing off, I was able to make changes to my page. Turning Heartbeat off can be done by simply deregistering the script:
add_action( 'init', 'remove_heartbeat');
function remove_heartbeat() {
wp_deregister_script('heartbeat');
}
(via Aditya Nath Jha
This content originally appeared on Hidde's blog and was authored by Hidde de Vries
Hidde de Vries | Sciencx (2016-02-08T00:00:00+00:00) Turning off Heartbeat in WordPress made my day!. Retrieved from https://www.scien.cx/2016/02/08/turning-off-heartbeat-in-wordpress-made-my-day/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.