Hosting & Server Optimization
Hosting Types
| Type | Speed | Cost | Best For |
|---|---|---|---|
| Shared | Slow | $5-20/mo | Small blogs |
| VPS | Good | $20-100/mo | Growing sites |
| Managed WP | Fast | $30-300/mo | Business sites |
| Cloud | Scalable | Variable | High traffic |
| Dedicated | Fastest | $200+/mo | Enterprise |
Managed WordPress Hosts
Top performers for WordPress-specific optimization:
| Host | Highlights |
|---|---|
| Cloudways | Flexible, affordable |
| Kinsta | Google Cloud, fast |
| WP Engine | Enterprise features |
| Flywheel | Designer-friendly |
| SiteGround | Good support |
PHP Optimization
PHP Version
Always use the latest stable PHP version:
// Check current version
echo phpversion();
// PHP 8.2+ is recommended
// 30-50% faster than PHP 7.4PHP Configuration
; php.ini optimizations
; Memory limit
memory_limit = 256M
; Execution time
max_execution_time = 300
; OPcache settings
opcache.enable = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 60
opcache.fast_shutdown = 1
opcache.enable_cli = 0
; Realpath cache
realpath_cache_size = 4096K
realpath_cache_ttl = 600PHP-FPM Tuning
; /etc/php/8.2/fpm/pool.d/www.conf
; Process manager
pm = dynamic
pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500
; Calculate max_children:
; (Total RAM - System RAM) / Average PHP Process Size
; Example: (4GB - 1GB) / 60MB = 50Web Server Configuration
Nginx Optimization
# /etc/nginx/nginx.conf
worker_processes auto;
worker_connections 2048;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml;
# FastCGI caching
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
# Brotli (if available)
brotli on;
brotli_types text/plain text/css application/json application/javascript;Apache Optimization
# .htaccess
# Enable compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json
</IfModule>
# Enable Keep-Alive
<IfModule mod_headers.c>
Header set Connection keep-alive
</IfModule>
# ETags
FileETag MTime SizeMySQL/MariaDB Tuning
# /etc/mysql/mysql.conf.d/performance.cnf
[mysqld]
# InnoDB settings
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
# Query cache (MySQL 5.7, deprecated in 8.0)
query_cache_type = 1
query_cache_size = 64M
query_cache_limit = 2M
# Connection settings
max_connections = 150
wait_timeout = 300
interactive_timeout = 300
# Buffer sizes
key_buffer_size = 256M
sort_buffer_size = 4M
read_buffer_size = 4Mwp-config.php Optimizations
// Memory limit
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');
// Reduce revisions
define('WP_POST_REVISIONS', 3);
// Autosave interval (seconds)
define('AUTOSAVE_INTERVAL', 120);
// Empty trash sooner (days)
define('EMPTY_TRASH_DAYS', 7);
// Disable cron if using system cron
define('DISABLE_WP_CRON', true);
// Faster image processing
define('WP_IMAGE_EDIT_OVERWRITE', true);
// External HTTP optimizations
define('WP_HTTP_BLOCK_EXTERNAL', false);System-Level Cron
# Disable WordPress internal cron (in wp-config.php)
# define('DISABLE_WP_CRON', true);
# Add system cron job
crontab -e
# Run every 5 minutes
*/5 * * * * cd /var/www/html && php wp-cron.php > /dev/null 2>&1
# Or with WP-CLI
*/5 * * * * cd /var/www/html && wp cron event run --due-now > /dev/null 2>&1Monitoring & Alerts
UptimeRobot / Pingdom
Set up monitoring:
- HTTP check every 1-5 minutes
- Alert on response time > 3s
- Alert on downtime
Server Monitoring
# Install Netdata for real-time monitoring
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
# Or use htop for quick checks
htopPerformance Checklist
| Item | Status |
|---|---|
| PHP 8.0+ | โ |
| OPcache enabled | โ |
| Page caching | โ |
| Object caching (Redis) | โ |
| CDN configured | โ |
| Gzip/Brotli enabled | โ |
| HTTP/2 enabled | โ |
| Database optimized | โ |
| Images optimized | โ |
| CSS/JS minified | โ |
Congratulations!
You've completed the WordPress Performance Optimization tutorial!
What You've Learned
- โ Core Web Vitals and measurement
- โ Multi-level caching strategies
- โ Image optimization techniques
- โ Database maintenance and tuning
- โ CSS/JS optimization
- โ Profiling and debugging
- โ Server-level optimization
Target Performance
| Metric | Target |
|---|---|
| LCP | < 2.5s |
| INP | < 200ms |
| CLS | < 0.1 |
| TTFB | < 600ms |
| Lighthouse | 90+ |
๐ฏ Tutorial Complete! You're now equipped to build blazing-fast WordPress sites.