Shared hosting is like a crowded apartment: limited resources, resource-hungry neighbors, and potential slowdowns during peak hours. If your WordPress site is hosted on such a server, WordPress optimization is not a choice but a necessity. Without optimization, even a simple site can fail speed tests and drive visitors away. In this article, we review practical and actionable techniques for optimizing WordPress on shared hosting: from caching and compression to database cleanup and managing resource-heavy plugins. Everything is presented with real examples and precise commands.
1. Caching: The First and Most Important Step in WordPress Optimization
Caching means storing a static version of WordPress dynamic pages. When a user opens a page, instead of re-running PHP and MySQL queries, the cached version is delivered. This reduces server load by up to 80% and cuts loading time from 3-4 seconds to under 1 second.
Choosing the Right Caching Plugin for Shared Hosting
For shared hosting, free and lightweight caching plugins like WP Super Cache or W3 Total Cache are good options. However, my recommendation is WP Rocket (paid) because its settings are simpler and it consumes fewer resources. If you have no budget, try LiteSpeed Cache if your host uses a LiteSpeed server (you can check the server type with the command curl -I yoursite.com | grep Server).
Basic Cache Settings in WP Super Cache
- Install and activate the plugin.
- Go to Settings → WP Super Cache.
- Enable the Caching On option.
- In the Advanced section, check Use mod_rewrite to serve cache files (if your host supports mod_rewrite).
- Set the cache expiry time to 3600 seconds (1 hour). For news sites that update frequently, 1800 seconds is sufficient.
Important Note: If you use WooCommerce or membership plugins, make sure to enable the Don't cache pages for known users option so logged-in users see fresh content.
Browser Caching with Gzip Compression
Browser caching tells the user's browser to store static files (CSS, JS, images) for a specified period. To enable it, add the following code to the .htaccess file in the WordPress root:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
</IfModule>
Gzip compression also reduces the size of sent files by up to 70%. Add this code to .htaccess:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript
</IfModule>
You can check performance with the Gzip Test tool.
2. Image Compression: Reducing Size Without Losing Quality
Images typically account for 60-70% of a page's weight. Smart compression can reduce size by 40-80%.
Image Compression Plugins
- Smush: Free and popular. Compresses up to 5 MB. Its default settings are sufficient.
- ShortPixel: Free version offers 100 images per month. Higher quality and better compression.
- EWWW Image Optimizer: No size limit, but requires server resources.
To use Smush, simply install the plugin and go to Media → Smush, then click Bulk Smush. The default settings (compression at 82% quality) are suitable for most sites.
Manual Compression with Online Tools
If you prefer not to install a plugin, compress images before uploading using TinyPNG or Compressor.io. For example, a 1.2 MB PNG image can be reduced to 300 KB with TinyPNG without noticeable quality loss.
3. Database Cleanup: Removing WordPress Junk
Over time, the WordPress database fills with useless data: post revisions, spam comments, extra meta, and expired transients. This data slows down queries and increases database size.
Best Plugin for Database Cleanup
WP-Optimize is a free and powerful plugin. To use it:
- Install and activate the plugin.
- Go to WP-Optimize → Database.
- Check the following options:
- Remove all post revisions
- Remove all spam comments
- Remove all trashed comments
- Remove expired transients
- Optimize database tables
- Click Run Optimization.
Do this once a month. On a site with 1000 posts, this typically frees up 50-100 MB of extra space.
Manual Cleanup with phpMyAdmin
If you have database access, you can use phpMyAdmin. First, back up the database. Then run the following query to delete post revisions:
DELETE FROM wp_posts WHERE post_type = 'revision';
Note: The table prefix may not be wp_. Find it in the wp-config.php file.
Common Mistake: Manually deleting wp_options records without checking. This table contains critical settings. Only delete records related to expired transients (using DELETE FROM wp_options WHERE option_name LIKE '%_transient_%' AND option_value IS NULL).
4. Managing Resource-Heavy Plugins: Identification and Replacement
Resource-heavy plugins like bulky sliders, heavy page builders, and feature-rich security plugins consume server resources. To identify them:
Using Query Monitor
Install the Query Monitor plugin. This tool shows how many queries each plugin makes to the database and how long it takes. If a plugin generates more than 50 queries on a simple page, you should find a replacement.
For example, a typical slider plugin makes 20-30 queries, but a professional slider like Revolution Slider may make 100+ queries. In such cases, use lighter sliders like MetaSlider.
Replacing Heavy Plugins
- Replace Yoast SEO: Use Rank Math, which is lighter and makes fewer queries.
- Replace Contact Form 7: Use Fluent Forms or WPForms Lite.
- Replace Jetpack: Activate only essential modules or use separate plugins like Akismet for spam and VaultPress for backups.
Test: Disable a plugin and measure speed with GTmetrix or PageSpeed Insights. If there is noticeable improvement, remove that plugin.
5. Basic WordPress Optimization Without Plugins
Some settings can be applied directly to WordPress files:
Limiting Post Revisions
Add this line to the wp-config.php file to limit the number of revisions:
define('WP_POST_REVISIONS', 5);
This means only the last 5 versions of each post are saved. The default value is unlimited.
Disabling XML-RPC
XML-RPC is an old protocol used for connecting external applications. If you don't use it, disable it with the Disable XML-RPC plugin or the following code in .htaccess:
<Files xmlrpc.php>
Order Deny,Allow
Deny from all
</Files>
This also reduces brute force attacks.
6. Continuous Monitoring and Testing
One-time optimization is not enough. Check performance monthly with the following tools:
- GTmetrix: Loading time and optimization recommendations.
- PageSpeed Insights: Core Web Vitals score.
- Pingdom Tools: Testing from different global locations.
Goal: Loading time under 2 seconds and PageSpeed score above 80 for mobile and 90 for desktop.
Conclusion
Optimizing WordPress on shared hosting is not difficult, but it requires attention and persistence. By implementing the steps in this article—caching, image compression, database cleanup, and plugin management—you can significantly increase your site's speed. Remember: test every change in a staging environment first and always back up your database and files. If you are looking for hosting with more dedicated resources, ServerNet offers various options from shared hosting to cloud servers that can meet your needs. But more important than the type of hosting is the correct implementation of optimization techniques. Start and see the results in reduced bounce rates and increased user satisfaction.