How to Tune WordPress Performance Using Advanced Wp-config.php Configuration Constants
Learning how to tune WordPress performance using advanced wp-config.php configuration constants is one of the most effective ways to speed up your site without installing extra plugins. Most WordPress admins focus on caching plugins and CDNs, but wp-config.php gives you direct control over core behaviors. You can manage memory limits, disable unnecessary file edits, control revision storage, and fine-tune database connections , all from a single file. This tutorial walks you through the most impactful constants you can add or modify. By the end, you’ll have a faster, leaner WordPress installation running on your server.
Prerequisites and Requirements for Wp-config.php Tuning
Before you start tweaking wp-config.php, make sure you meet these requirements.
Required access and tools:
- SSH access to your Linux server (Ubuntu, Debian, or CentOS)
- A text editor like
nanoorvim - Root or sudo privileges
- A working WordPress installation
- A recent backup of your wp-config.php file
Assumed knowledge:
- Basic Linux command-line skills
- Familiarity with WordPress file structure
- Understanding of PHP memory and server resources
Estimated time: 20–30 minutes
Always back up wp-config.php before making changes. One typo can break your entire site. Run this command to create a quick backup:
cp /var/www/html/wp-config.php /var/www/html/wp-config.php.bak
You can verify the backup exists with ls -lh /var/www/html/wp-config.php.bak. Once that’s done, you’re ready to start editing.
How to Tune WordPress Performance Using Wp-config.php Constants
For a related walkthrough, see: How to Configure DNS Over HTTPS (doh) on Ubuntu Using Dnscrypt-proxy
Follow these steps carefully. Add each constant inside wp-config.php, above the line that reads / That's all, stop editing! /.
Open the file with your editor:
sudo nano /var/www/html/wp-config.php
Step 1: Increase the PHP Memory Limit
WordPress defaults to 40MB of memory. That’s too low for most modern sites. Bump it up to 256MB or higher depending on your server RAM.
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
WP_MEMORY_LIMIT controls front-end memory. WP_MAX_MEMORY_LIMIT covers the admin panel. Set the admin limit higher to handle large imports and plugin operations.
Step 2: Limit Post Revisions
WordPress saves a revision every time you update a post. This bloats your database fast. Limit revisions to 3 or 5 per post.
define( 'WP_POST_REVISIONS', 3 );
You can also disable revisions entirely by setting this to false. For active blogs, keeping 3–5 revisions is a good balance.
Step 3: Set the Autosave Interval
WordPress autosaves drafts every 60 seconds by default. This creates extra database writes. Increase the interval to reduce load.
define( 'AUTOSAVE_INTERVAL', 300 );
This sets autosave to every 5 minutes. Your writers still get draft protection. Your database gets fewer unnecessary writes.
Step 4: Disable the File Editor
The built-in theme and plugin editor is a security risk. It also adds overhead to the admin panel. Disable it entirely.
define( 'DISALLOW_FILE_EDIT', true );
This removes the editor from the admin menu. It also prevents malicious code injection through a compromised admin account.
Step 5: Control the Trash Emptying Schedule
WordPress moves deleted posts to trash. By default, it empties the trash every 30 days. You can shorten this to keep your database clean.
define( 'EMPTY_TRASH_DAYS', 7 );
Set it to 0 to skip the trash entirely and delete posts permanently. Use that option carefully.
Step 6: Enable and Configure WordPress Caching
WordPress has a built-in object cache flag. Enabling it tells WordPress to use an object cache if one is available, like Redis or Memcached.
define( 'WP_CACHE', true );
This constant alone won’t activate caching. You need a caching plugin or a drop-in like object-cache.php in your wp-content folder. Check the official WordPress wp-config.php documentation for a full list of supported constants.
Step 7: Optimize Database Table Compression
If you use MySQL or MariaDB, you can optimize your WordPress tables periodically. This isn’t a wp-config.php constant, but it pairs well with your other changes. Run this from the command line:
mysqlcheck -u root -p --optimize --all-databases
Enter your MySQL root password when prompted. This reclaims space from deleted rows and speeds up queries.
Step 8: Disable Concatenation of Admin Scripts
WordPress concatenates admin scripts to reduce HTTP requests. On HTTP/2 servers, this actually slows things down. Disable it if your server uses HTTP/2.
define( 'CONCATENATE_SCRIPTS', false );
Check your server’s HTTP version with curl -I https://yourdomain.com and look for HTTP/2 in the response. Only apply this constant if you confirm HTTP/2 is active.
Save and close the file with CTRL+X, then Y, then Enter.
Troubleshooting Common Wp-config.php Performance Issues
Even careful edits can cause problems. Here are the most common issues and how to fix them.
White screen of death after saving:
You likely have a syntax error. Restore your backup immediately.
cp /var/www/html/wp-config.php.bak /var/www/html/wp-config.php
Then re-edit the file and check for missing semicolons or mismatched quotes.
Memory limit not applying:
Your PHP configuration may override the WordPress constant. Check your php.ini file.
php -i | grep memory_limit
If the server-level limit is lower than what you set in wp-config.php, update php.ini directly. Find the file with php --ini and change the memory_limit value there.
Caching not working after enabling WP_CACHE:
The WP_CACHE constant requires a compatible caching layer. Install a plugin like W3 Total Cache or WP Super Cache. Alternatively, set up Redis and place the appropriate object-cache.php drop-in inside /var/www/html/wp-content/.
Database optimization command fails:
Make sure the MySQL client is installed. On Ubuntu, run sudo apt install mysql-client -y. Also confirm your database credentials are correct. For a full reference on MySQL performance tuning, visit the MySQL 8.0 Optimization documentation.
Admin scripts disabled but site feels slower:
Disabling concatenation only helps on HTTP/2. If your server still uses HTTP/1.1, remove the CONCATENATE_SCRIPTS constant and let WordPress handle script bundling.
Conclusion: Applying Advanced Wp-config.php Configuration Constants
You now know how to tune WordPress performance using advanced wp-config.php configuration constants that target memory, database efficiency, caching, and security. These changes are lightweight. They don’t require extra plugins. They work at the core level of WordPress itself.
Start with the memory limit and revision controls. Those two changes alone will make a measurable difference on most sites. Then work through the remaining constants one at a time. Test your site after each change using a tool like Google PageSpeed Insights.
From here, consider pairing these constants with server-level optimizations. PHP-FPM tuning, Nginx configuration, and Redis object caching all complement what you’ve done in wp-config.php. Each layer adds up to a noticeably faster WordPress site.
