🚀 Introduction to WordPress Optimization
Optimizing WordPress involves addressing both server-side and application-side configurations that will
significantly boost your WordPress site speed and reliability. The most important step in optimizing
WordPress is caching.
📌 Important Note: Some optimizations may interfere with plugin functionality. Always
check the NGINX server logs (/var/log/nginx/) and PHP logs (/var/log/) if
issues arise.
Optimization Strategy Overview
Server-Side Optimization
→
Application-Side Optimization
→
Caching Layer
→
CDN Integration
Server-Side Optimizations
- FastCGI Caching: NGINX-based page caching
- PHP OPcache: PHP bytecode caching
- PHP-FPM Tuning: Process manager optimization
- Redis Object Cache: In-memory data caching
Application-Side Optimizations
- Increase WordPress max memory limit
- Replace WordPress cron with server-side cron
- Optimize post revisions policy
- Image and database optimization
- CSS and JavaScript minification
- Caching and performance plugins
Performance Testing
Use PageSpeed.web.dev to analyze your site and identify optimization opportunities. Aim
for scores above 90 for both mobile and desktop.
✅ Performance Goals:
- Mobile Score: 90+
- Desktop Score: 90+
- Time to First Byte (TTFB): < 200ms
- First Contentful Paint (FCP): < 1.8s
📝 WordPress Post Revisions Management
WordPress automatically saves multiple revisions of your posts and pages. While useful for content
recovery, excessive revisions can bloat your database and slow down your site.
Disable Post Revisions
Navigate to your WordPress configuration file:
cd /var/www/example.com/
sudo nano public_html/wp-config.php
Add the following directive to disable post revisions:
define('WP_POST_REVISIONS', false);
💡 Alternative Configuration: Instead of completely disabling revisions, you can limit
them to a specific number:
define('WP_POST_REVISIONS', 3);
Restart PHP-FPM to apply changes:
sudo systemctl restart php8.3-fpm
Impact Analysis
| Configuration |
Database Impact |
Use Case |
| Unlimited Revisions (Default) |
High storage usage |
Multiple authors, frequent edits |
| Limited Revisions (3-5) |
Moderate storage usage |
Balanced approach |
| Disabled Revisions |
Minimal storage usage |
Single author, static content |
💾 PHP Memory Limit Configuration
Increasing the PHP memory limit allows WordPress to handle more complex operations, larger plugins, and
high-traffic scenarios without running out of memory.
Configure PHP-FPM Pool Memory Limit
cd /etc/php/8.3/fpm/pool.d/
sudo nano example.com.conf
Modify or add the memory limit directive:
;php_admin_value[memory_limit] = 32M
php_admin_value[memory_limit] = 256M
Configure WordPress Memory Limit
cd /var/www/example.com/
sudo nano public_html/wp-config.php
Add the following directive:
/** MEMORY LIMIT */
define('WP_MEMORY_LIMIT', '256M');
Restart PHP-FPM:
sudo systemctl restart php8.3-fpm
Memory Limit Guidelines
| Site Type |
Recommended Memory |
Description |
| Simple Blog |
128M |
Basic WordPress with minimal plugins |
| Standard Website |
256M |
Multiple plugins, moderate traffic |
| WooCommerce Store |
512M |
E-commerce with extensive plugins |
| High-Traffic Site |
1024M+ |
Complex operations, heavy processing |
⚠️ Warning: Setting memory limits too high can lead to resource exhaustion if multiple
processes consume maximum memory simultaneously. Monitor your server resources carefully.
⏰ WordPress Cron Replacement
By default, WordPress uses a pseudo-cron system that triggers on page loads, which can cause performance
issues and unreliable scheduled task execution. Replacing it with a real server-side cron job ensures
scheduled tasks run reliably without impacting site performance.
Disable WordPress Built-in Cron
cd /var/www/example.com/
sudo nano public_html/wp-config.php
Add the following directive:
define('DISABLE_WP_CRON', true);
Restart PHP-FPM:
sudo systemctl restart php8.3-fpm
Configure Server-Side Cron Job
Open the crontab editor:
Add the following cron job (runs every 15 minutes):
*/15 * * * * wget -q -O - https://example.com/wp-cron.php?doing_wp_cron
>/dev/null 2>&1
Cron Job Frequency Options
| Schedule |
Cron Expression |
Use Case |
| Every 5 minutes |
*/5 * * * * |
High-frequency updates |
| Every 15 minutes |
*/15 * * * * |
Standard WordPress (Recommended) |
| Every 30 minutes |
*/30 * * * * |
Low-frequency tasks |
| Every hour |
0 * * * * |
Minimal scheduled tasks |
📌 Benefits of Server-Side Cron:
- Reliable execution regardless of site traffic
- No performance impact on visitor page loads
- Predictable scheduling
- Better resource management
⚡ PHP OPcache Configuration
OPcache is a PHP bytecode cache that stores precompiled script bytecode in memory, dramatically improving
PHP execution speed by eliminating the need to parse and compile PHP scripts on every request.
Navigate to PHP-FPM Pool Configuration
cd /etc/php/8.3/fpm/pool.d/
ls
sudo nano example.com.conf
Development Server Configuration
For development environments where files change frequently:
; OPCACHE CONFIGURATION - DEVELOPMENT SERVER - Jul 2025
; Directive php_admin_flag[opcache.enabled] leave commented - enabled by
default
; php_admin_flag[opcache.enabled] = 1
php_admin_value[opcache.memory_consumption] = 256
php_admin_value[opcache.interned_strings_buffer] = 32
php_admin_value[opcache.max_accelerated_files] = 20000
php_admin_flag[opcache.validate_timestamps] = 1
php_admin_value[opcache.revalidate_freq] = 2
php_admin_flag[opcache.validate_permission] = 1
Production Server Configuration
For production environments optimized for maximum performance:
; OPCACHE CONFIGURATION - PRODUCTION SERVER - Jul 2025
; Directive php_admin_flag[opcache.enabled] leave commented - enabled by
default
;php_admin_flag[opcache.enabled] = 1
;php_admin_value[opcache.memory_consumption] = 256
;php_admin_value[opcache.interned_strings_buffer] = 32
;php_admin_value[opcache.max_accelerated_files] = 20000
;php_admin_value[opcache.validate_timestamps] = 0
;php_admin_flag[opcache.validate_permission] = 1
Apply Configuration Changes
sudo systemctl reload php8.3-fpm
Calculate Required max_accelerated_files
Count the number of PHP files in your WordPress installation:
cd /var/www/
sudo find . -type f -print | grep php | wc -l
💡 Tip: Set
max_accelerated_files to the next highest prime number after
your PHP file count. For reference, visit:
PHP OPcache Documentation
OPcache Configuration Parameters Explained
| Parameter |
Development |
Production |
Description |
| memory_consumption |
256M |
256M |
Memory allocated for OPcache |
| interned_strings_buffer |
32M |
32M |
Memory for storing interned strings |
| max_accelerated_files |
20000 |
20000 |
Maximum number of cached PHP files |
| validate_timestamps |
1 (On) |
0 (Off) |
Check for file modifications |
| revalidate_freq |
2 seconds |
N/A |
Frequency of timestamp checks |
OPcache Performance Flow
PHP Request
→
Check OPcache
→
Cached Bytecode
→
Execute
Without OPcache: Parse → Compile → Execute (every request)
With OPcache: Execute (cached bytecode)
🚄 FastCGI Caching Setup
FastCGI caching is a powerful NGINX feature that caches dynamic content, significantly reducing server
load and improving response times for WordPress sites.
Configure NGINX Main Configuration
cd /etc/nginx
sudo nano nginx.conf
Add the following directives in the HTTP context (before # Virtual Host Configs):
### FASTCGI CACHING
# fastcgi_cache_path directive - PATH & NAME must be unique for each site
# Add a new fastcgi_cache_path for each site and give a new keys_zone name
fastcgi_cache_path /var/run/SITE levels=1:2 keys_zone=NAME:100m inactive=60m;
# applied to all sites
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
Create Cache Exclusion Rules
cd /etc/nginx/includes/
sudo nano fastcgi_cache_excludes.conf
Add the following exclusion rules:
# NGINX SKIP CACHE INCLUDE FILE
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache uris containing the following segments
if ($request_uri ~*
"/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~*
"comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
Configure Site-Specific Settings
cd /etc/nginx/sites-available
sudo nano example.com.conf
Add these directives to your server block:
include /etc/nginx/includes/fastcgi_cache_excludes.conf;
add_header X-FastCGI-Cache $upstream_cache_status;
In the PHP location block, add:
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache NAME;
fastcgi_cache_valid 60m;
Add Cache Purge Functionality
Add a purge location to your server block:
location ~ /purge(/.*) {
fastcgi_cache_purge NAME "$scheme$request_method$host$1";
}
Test and Apply Configuration
sudo nginx -t
sudo systemctl reload nginx
Verify FastCGI Cache is Working
curl -I https://example.com
curl -I https://www.example.com
💡 Cache Status Headers:
- HIT: Content served from cache
- MISS: Content not in cache, fetched from PHP
- BYPASS: Cache intentionally bypassed
- EXPIRED: Cached content expired, refreshing
Remove FastCGI Caching
If you need to disable FastCGI caching:
cd /etc/nginx/sites-available
sudo nano example.com.conf
Remove or comment out these directives:
# include /etc/nginx/includes/fastcgi_cache_excludes.conf;
# add_header X-FastCGI-Cache $upstream_cache_status;
# fastcgi_cache_bypass $skip_cache;
# fastcgi_no_cache $skip_cache;
# fastcgi_cache NAME;
# fastcgi_cache_valid 60m;
Remove the purge location and reload:
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl restart php8.3-fpm
🔌 WP Super Cache Integration
WP Super Cache is a popular WordPress caching plugin that generates static HTML files from your dynamic
WordPress site. When integrated with NGINX, it provides excellent performance improvements.
Create WP Super Cache Exclusion Rules
cd /etc/nginx/includes/
sudo nano wp_super_cache_excludes.conf
Add the following configuration:
# WP Super Cache NGINX Cache Exclusions Rules.
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache uris containing the following segments
if ($request_uri ~*
"(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)")
{
set $cache_uri 'null cache';
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~*
"comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Use cached or actual file if they exists, otherwise pass request to
WordPress
location / {
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index-https.html
$uri $uri/ /index.php?$args ;
}
Configure NGINX Site Configuration
cd /etc/nginx/sites-available/
sudo nano example.com.conf
Include the WP Super Cache exclusions file:
include /etc/nginx/includes/wp_super_cache_exclusions.conf;
Apply Configuration
sudo nginx -t
sudo systemctl reload nginx
Uninstalling WP Super Cache
To remove WP Super Cache configuration:
cd /etc/nginx/sites-available/
sudo nano example.com.conf
Remove the include directive and uncomment the default location block:
# REMOVE:
# include /etc/nginx/includes/wp_super_cache_exclusions.conf;
# UNCOMMENT:
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl reload php8.3-fpm
📌 WP Super Cache Features:
- Generates static HTML files
- Serves cached content without PHP execution
- Supports CDN integration
- Mobile device detection
- Cache preloading
⚙️ W3 Total Cache Configuration
W3 Total Cache (W3TC) is a comprehensive WordPress performance optimization plugin that provides
extensive caching capabilities including page cache, object cache, database cache, and more.
Prepare nginx.conf File
cd /var/www/example.com/public_html/
sudo touch nginx.conf
sudo chown username:username nginx.conf
sudo chmod 660 nginx.conf
sudo ls -l
Secure nginx.conf File
cd /etc/nginx/includes/
sudo nano nginx_security_directives.conf
Add the following security directive:
location = /nginx.conf { deny all; }
Create W3TC Cache Exclusion Rules
cd /etc/nginx/includes/
sudo nano w3tc_cache_excludes.conf
Add the following configuration:
# ---------------------
# W3 TOTAL CACHE EXCLUDES FILE
# ---------------------
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache uris containing the following segments
if ($request_uri ~*
"(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)")
{
set $cache_uri 'null cache';
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~*
"comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Use cached or actual file if file exists, otherwise pass request to
WordPress
location / {
try_files /wp-content/w3tc/pgcache/$cache_uri/_index.html $uri $uri/
/index.php?$args;
}
Configure NGINX Site
cd /etc/nginx/sites-available/
sudo nano example.com.conf
Comment out the default location block and add W3TC includes:
#location / {
# try_files $uri $uri/ /index.php$is_args$args;
#}
include /etc/nginx/includes/w3tc_cache_excludes.conf;
include /var/www/example.com/public_html/nginx.conf;
Install PHP Tidy Extension (Required for W3TC)
sudo apt update
sudo apt install php8.3-tidy
Apply Configuration
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl reload php8.3-fpm
Uninstall W3 Total Cache
cd /etc/nginx/sites-available/
sudo nano example.com.conf
Restore default location block and remove includes:
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# Remove these lines:
# include /etc/nginx/includes/w3tc_cache_excludes.conf;
# include /var/www/example.com/public_html/nginx.conf;
Clean up W3TC files:
cd /var/www/example.com/public_html/wp-content/
sudo rm -rf cache/ w3tc-config/
cd /var/www/example.com/public_html/
sudo rm nginx.conf
sudo systemctl reload php8.3-fpm
sudo systemctl reload nginx
💡 W3 Total Cache Features:
- Page caching (Disk: Enhanced, Basic, memcached, Redis)
- Database caching
- Object caching
- Browser caching
- CDN integration
- Minification of HTML, CSS, and JavaScript
- Lazy loading images
🔴 Redis Object Caching
Redis is an in-memory data structure store that can be used as a database cache and message broker. When
integrated with WordPress, it provides ultra-fast object caching, significantly improving database query
performance.
Install Redis and PHP Redis Extension
sudo apt update
sudo apt install redis-server php8.3-redis
Verify Redis Installation
sudo systemctl status redis-server
Check Redis logs for errors:
sudo cat /var/log/redis/redis-server.log
Fix Memory Overcommit Warning
If you see the warning "overcommit_memory is set to 0", fix it by creating a sysctl configuration:
cd /etc/sysctl.d/
sudo nano 11-redis.conf
Add the following line:
Reboot the server:
Verify the fix:
sudo systemctl status redis-server
sudo cat /var/log/redis/redis-server.log
Configure Redis Memory Settings
cd /etc/
sudo ls redis/
sudo nano redis/redis.conf
Add or modify these directives:
maxmemory 256mb
maxmemory-policy allkeys-lru
sudo systemctl restart redis-server
sudo reboot
Configure WordPress for Redis
cd /var/www/example.com/public_html/
sudo nano wp-config.php
Add the Redis cache key salt (use your domain name):
define('WP_CACHE_KEY_SALT', 'example.com');
WooCommerce Redis Configuration
If using WooCommerce, you need to prevent Redis from caching session data. Add this to wp-config.php:
/** PREVENT REDIS CACHING WOO SESSION DATA */
define('WP_REDIS_IGNORED_GROUPS', 'wc_session');
⚠️ WooCommerce Cache Exclusions:
The following URLs and cookies should be excluded from caching:
- URLs: /cart/, /my-account/, /checkout/
- Cookies: woocommerce_cart_hash, woocommerce_items_in_cart,
wp_woocommerce_session_, woocommerce_recently_viewed, store_notice[notice id], _wc_session_
For detailed configuration instructions, visit: WooCommerce Caching Documentation
Redis Memory Policy Options
| Policy |
Description |
Use Case |
| allkeys-lru |
Evict least recently used keys |
General purpose (Recommended) |
| allkeys-lfu |
Evict least frequently used keys |
Hot data optimization |
| volatile-lru |
Evict LRU keys with expiration set |
Mixed persistent/temporary data |
| noeviction |
Return errors when memory limit reached |
Critical data protection |
Redis Caching Architecture
WordPress Request
→
Check Redis Cache
→
Return Cached Object
Cache Miss
→
Query MySQL
→
Store in Redis
→
Return Data
⚙️ PHP-FPM Optimization
PHP-FPM (FastCGI Process Manager) is the PHP processor that NGINX uses to execute PHP code. Properly
configuring PHP-FPM is crucial for optimal WordPress performance.
Calculate Average Memory Per PHP Process
First, identify your PHP-FPM pool usernames:
grep -E '^\s*user\s*=' /etc/php/8.3/fpm/pool.d/*.conf | awk -F= '{print $2}' |
xargs | tr ' ' '\n' | sort -u
Calculate average memory usage (replace POOL_USER with actual username):
ps -C php-fpm --user POOL_USER -o rss= | awk '{ sum += $1; count++ } END { if
(count > 0) printf ("%d%s\n", sum/NR/1024,"M") }'
Configure OnDemand Process Manager
cd /etc/php/8.3/fpm/pool.d/
ls
sudo nano example.com.conf
Configure the process manager settings:
pm = ondemand
pm.max_children = [calculated_value]
pm.process_idle_timeout = 10s
pm.max_requests = 500
Apply Configuration
sudo systemctl reload php8.3-fpm
Monitor for max_children Warnings
ls /var/log/
sudo grep max_children /var/log/php8.3-fpm.log
⚠️ Warning Message:
If you see:
WARNING: [pool www] server reached max_children setting (25), consider raising it
You need to increase the pm.max_children value.
Calculate pm.max_children
Formula:
pm.max_children = (Total Available RAM - Reserved RAM) / Average Process Memory
Example Calculation:
Server RAM: 4GB (4096MB)
Reserved for system: 1GB (1024MB)
Available for PHP: 3GB (3072MB)
Average process memory: 40MB
pm.max_children = 3072 / 40 = 76 (round down to 75 for safety)
PHP-FPM Process Manager Modes
| Mode |
Description |
Pros |
Cons |
| static |
Fixed number of child processes |
Predictable, consistent performance |
Wastes resources during low traffic |
| dynamic |
Spawns children as needed |
Flexible, adaptive to traffic |
Slight overhead from spawning |
| ondemand |
Creates processes only when needed |
Minimal resource usage when idle |
Initial request latency |
OnDemand Configuration Parameters
| Parameter |
Description |
Recommended Value |
| pm.max_children |
Maximum number of child processes |
Calculated based on available RAM |
| pm.process_idle_timeout |
Time before idle process terminates |
10s (low traffic) to 30s (high traffic) |
| pm.max_requests |
Requests before process restart |
500 (prevents memory leaks) |
PHP-FPM OnDemand Process Lifecycle
Request Arrives
→
Spawn Process
→
Handle Request
→
Idle Timeout
→
Terminate
☁️ Cloudflare Integration
Cloudflare provides CDN services, DDoS protection, and web application firewall features. When using
Cloudflare, NGINX needs to be configured to recognize the real visitor IP addresses instead of
Cloudflare's proxy IPs.
Get Cloudflare IP Ranges
Cloudflare maintains official lists of their IP ranges:
Create Cloudflare IP List Configuration
cd /etc/nginx/includes
sudo nano cloudflare_ip_list.conf
Add the Cloudflare IP ranges:
# Last updated OCT 2022
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 104.24.0.0/14;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2405:8100::/32;
set_real_ip_from 2a06:98c0::/29;
set_real_ip_from 2c0f:f248::/32;
real_ip_header CF-Connecting-IP;
Include in Site Configuration
cd /etc/nginx/sites-available/
sudo nano example.com.conf
Add the include directive to your server block:
include /etc/nginx/includes/cloudflare_ip_list.conf;
Apply Configuration
sudo nginx -t
sudo systemctl reload nginx
💡 Important Notes:
- Auto Minify Deprecated: Cloudflare has deprecated the auto-minify feature.
Reference: Cloudflare Community Announcement
- Update IP List: Periodically check Cloudflare's official IP lists and update
your configuration
- Real IP Header: The
CF-Connecting-IP header contains the actual
visitor's IP address
Benefits of Cloudflare Integration
Visitor
→
Cloudflare CDN
→
Your Server
- DDoS Protection: Automatic mitigation of attacks
- CDN Caching: Static content served from edge locations
- SSL/TLS: Free SSL certificates and HTTPS
- Web Application Firewall: Protection against common threats
- Performance: Reduced latency through global network
✨ Best Practices & Recommendations
Plugin Selection Guidelines
When selecting WordPress plugins for optimization, consider these critical factors:
| Factor |
What to Check |
Why It Matters |
| Active Support |
Recent updates, developer responses |
Ensures compatibility and security |
| Documentation |
Comprehensive guides, examples |
Easier implementation and troubleshooting |
| Security History |
Past vulnerabilities, CVE records |
Protects your site from exploits |
| Compatibility |
WordPress version, PHP version |
Prevents conflicts and errors |
| Active Installations |
Number of active installs |
Indicates reliability and popularity |
| User Reviews |
Ratings, common issues |
Real-world feedback and experiences |
Image Optimization Strategy
Modern image optimization requires careful consideration of format support and compatibility:
WebP Format Adoption:
Nearly 97% of web browsers support WebP format. Site owners face a strategic decision:
- WebP Only: Simpler server configuration, better performance, but excludes 3% of
browsers
- Hybrid Approach: Serve WebP to supporting browsers, fallback to JPEG/PNG for
others - more complex but broader compatibility
Recommended Image Optimization Plugins:
Test these plugins on a development server first:
- Imagify
- ShortPixel Image Optimizer
- EWWW Image Optimizer
- Smush Pro
Database Optimization
⚠️ Critical: Always backup your database before running any optimization plugin!
Recommended Database Optimization Plugins:
- WP-Optimize
- Advanced Database Cleaner
- WP-Sweep
CSS and JavaScript Optimization
With Cloudflare deprecating auto-minify, you need to implement minification at the application level:
Minification vs. Concatenation:
| Technique |
Description |
Benefit |
| Minification |
Removes whitespace, comments, shortens variable names |
Reduces file size |
| Concatenation |
Combines multiple files into one |
Reduces HTTP requests |
Recommended Minification Plugins:
- Autoptimize
- Fast Velocity Minify
- Asset CleanUp
Performance Testing Workflow
Baseline Test
→
Implement Optimization
→
Test Performance
→
Compare Results
Document Changes
→
Monitor for Issues
→
Iterate
Monitoring and Maintenance
Regular Maintenance Tasks:
- Weekly: Check error logs, monitor cache hit rates
- Monthly: Update Cloudflare IP list, review plugin updates
- Quarterly: Full performance audit, database optimization
- Annually: Review entire optimization stack, test alternatives
Optimization Priority Matrix
| Priority |
Optimization |
Impact |
Complexity |
| 🔴 Critical |
FastCGI/Page Caching |
Very High |
Medium |
| 🔴 Critical |
OPcache |
Very High |
Low |
| 🟡 High |
Redis Object Cache |
High |
Medium |
| 🟡 High |
Image Optimization |
High |
Low |
| 🟢 Medium |
PHP-FPM Tuning |
Medium |
Medium |
| 🟢 Medium |
CSS/JS Minification |
Medium |
Low |
Troubleshooting Common Issues
✅ Log File Locations:
- NGINX Access Log: /var/log/nginx/access.log
- NGINX Error Log: /var/log/nginx/error.log
- PHP-FPM Log: /var/log/php8.3-fpm.log
- Redis Log: /var/log/redis/redis-server.log
Final Recommendations
💡 Key Takeaways:
- Always test optimizations on a development server first
- Implement changes incrementally and measure impact
- Keep regular backups before making configuration changes
- Monitor logs for errors and warnings
- Use browser console to debug JavaScript issues
- Aim for PageSpeed scores above 90 for both mobile and desktop
- Balance performance gains with configuration complexity
- Document all changes for future reference