WordPress Autosave: the silent crocodile.As a web host, our primary objective is to ensure that our servers, and consequently your websites, run optimally. Applications place an ever increasing demand on a servers resources as the software develops, and sometimes the 'default' settings of these applications need to be tweaked to ensure that they run happily on a shared web hosting environment. To ensure that we provide a stable service, our systems will detect when a web site hosted on our platform starts to use a disproportionate amount of a server's resources. Recently one of of the main issues we have seen is with WordPress, one of the most commonly installed applications on our servers, and the very same software that's running this blog.
In a recent WordPress release, they have introduced a feature to 'auto-save' every post or page you are editing constantly (via ajax, a silent process executed in the background). This is a fantastic feature for website editors as if you make any mistakes, you don't have to start all over again. However, the main problem with the ajax auto-save configuration, is that it can be executed more than once per minute. If you just type 1 or 2 words and suddenly stop writing, it will automatically save the post as a Draft again. You can notice that at the left bottom corner of the text area:
We have seen WordPress applications that execute more than 2000 times in a couple of hours, which can cause a significant load on a server, especially where there may be several hundred websites using WordPress. To make matters worse, if you have a number of plugins installed, these may also interact or call the auto-safe function while you are writing or publishing a post, and they may make an even greater demand on the server.
How can we increase the interval between each autosave?
Fortunately, WordPress, in their documentation explains how to accomplish that:
- Locate the file wp-config.php
- Open the file with your favourite text editor
- Scroll to the line where it says: /* That's all, stop editing! Happy blogging. */
- Before that line add the following:
define('AUTOSAVE_INTERVAL', 1800 ); // in seconds (the default is 60)
define('WP_POST_REVISIONS', false ); // it disable post revisions
Note: If you don't want to disable post revisions, you can limit WordPress to a certain number of revisions:
define('WP_POST_REVISIONS', 5); // the number of post revisions we want to keep.
The above are our recommended values, however, you might want to adjust it as you wish. In case you want to completely disable the autosave, you can define the autosave_interval to 86400 seconds, which is the amount of seconds in a entire day.
We hope all this information helped you understand one of the most important issues with WordPress and also how we also learn something new on a daily basis while working with all of you.
As always if you have any suggestion or recommendation on how can we improve our service, don't hesitate to let us know. We love receiving your feedback!