This tutorial shows you how to speed up WordPress with LiteSpeed Cache plugin (OpenLiteSpeed Web Server) + Cloudflare CDN. OpenLiteSpeed is the Open Source edition of LiteSpeed Web Server Enterprise. LiteSpeed Cache is one of the most powerful free WordPress cache plugins.
The VPS used in this article: DigitalOcean (1GB RAM, 1 vCore)
Get $100 of free DigitalOcean credits if you sign up through this link!
WordPress stack used in this article: DigitalOcean’s One-Click OpenLiteSpeed WordPress
Note: If you prefer to use the combination of Nginx FastCGI Cache + Redis Object Cache, please read this article.
Operating System: Ubuntu 20.04
Please add your domain name to Cloudflare in advance.
Please resolve your domain name to an IP address in advance.
Demo domain: 8.blogwp.ovh
Please replace 8.blogwp.ovh with your own domain name.
1、Install DigitalOcean’s One-Click OpenLiteSpeed WordPress
Login to DigitalOcean and click “Create a Droplet”
Click “Marketplace” from the “Choose an image” option, search and click “OpenLiteSpeed WordPress”
Choose a plan, choose a datacenter region, set a password, click “Create Droplet”
Connect to VPS (PuTTY)
login as: root [email protected]'s password: 0 updates can be installed immediately. 0 of these updates are security updates. The list of available updates is more than a week old. To check for new updates run: sudo apt update ******************************************************************************** Welcome to One-Click OpenLiteSpeed WordPress Server. To keep this server secure, the firewall is enabled. All ports are BLOCKED except 22 (SSH), 80 (HTTP) and 443 (HTTPS). WordPress One-Click Quickstart guide: * https://docs.litespeedtech.com/cloud/images/wordpress/ In a web browser, you can view: * The new WordPress site: http://126.96.36.199 * The phpMyAdmin: http://188.8.131.52/phpmyadmin On the server: * The default web root is located at /var/www/html * You can get the MySQL root password and MySQL WordPress user password with command: sudo cat .db_password * You can get the Web Admin admin password with the following command: sudo cat .litespeed_password * The WordPress Cache plugin, LSCache, is located at /var/www/html/wp-content/plugins/litespeed-cache * The phpMyAdmin is located at /var/www/phpmyadmin * A script will run that will allow you to add a domain to the web server and implement SSL. System Status: Load : 0.00, 0.00, 0.04 CPU : 3.81343% RAM : 225/981MB (22.94%) Disk : 2/25GB (11%) ******************************************************************************** Last login: Fri Dec 18 01:43:22 2020 from 184.108.40.206 To visit your apps by domain instead of IP, please enter a valid domain. If you don't have one yet, you may cancel this process by pressing CTRL+C and continuing to SSH. This prompt will open again the next time you log in, and will continue to do so until you finish the setup. Make sure the domain's DNS record has been properly pointed to this server. Enter the root domain only, then the system will add both the root domain and the www domain for you. Your domain: 8.blogwp.ovh The domain you put is: 8.blogwp.ovh Please verify it is correct. [y/N] y Domain has been added into OpenLiteSpeed listener. Do you wish to issue a Let's encrypt certificate for this domain? [y/N] n Do you wish to update the system now? This will update the web server as well. [Y/n]? n Enjoy your accelarated OpenLiteSpeed server!
Visit domain name, you will go directly to the WordPress installation interface and set the Username and Password:
2、Install LiteSpeed Cache plugin
LiteSpeed Cache Plugin Settings
Cache tab settings
Enable Cache: ON
Cache Logged-in Users: ON
Cache Commenters: ON
Cache REST API: ON
Cache Login Page: ON
Cache favicon.ico: ON
Cache PHP Resources: ON
Cache Mobile: OFF
TTL tab settings
You can set the cache time here, but you don’t need to change it unless you have a specific reason.
Default Public Cache TTL: 604800
Default Private Cache TTL: 1800
Default Front Page TTL: 604800
Default Feed TTL: 604800
Default REST TTL: 604800
Purge tab settings
Purge All On Upgrade: ON
Serve Stale: ON
Excludes tab settings
Here you can set what to exclude from the cache, but basically you don’t have to change it.
Object tab settings
Here you can turn the object cache on and off. If the Memcached extension or Redis extension is enabled and the connection test is passed, change it to on.
Object Cache: ON
Default Object Lifetime: 360
Browser tab settings
Browser caching stores static files locally in the user’s browser, if you enable the browser cache, the cache will be saved in the user’s web browser, and you can expect faster display.
Browser Cache: ON
Browser Cache TTL: 31557600
Advanced tab settings
Instant Click: ON
QUIC.cloud CDN: OFF
Use CDN Mapping: OFF
Cloudflare API: OFF
Page Optimization > CSS Settings
CSS Minify: OFF
CSS Combine: OFF
Unique CSS File: OFF
CSS HTTP/2 Push: ON
Load CSS Asynchronously: OFF
Generate Critical CSS: OFF
Generate Critical CSS In Background: OFF
Inline CSS Async Lib: ON
Page Optimization > JS Settings
JS Minify: OFF
JS Combine: OFF
JS Combine External and Inline: OFF
JS HTTP/2 Push: ON
Load JS Deferred: OFF
Load Inline JS: Default
Page Optimization > Optimization Settings
HTML Minify: ON
DNS Prefetch Control: OFF
Remove Query Strings: ON
Load Google Fonts Asynchronously: OFF
Remove Google Fonts: ON
Remove WordPress Emoji: ON
Remove Noscript Tag: ON
Page Optimization > Localization Settings
Gravatar Cache: ON
Gravatar Cache Cron: OFF
Gravatar Cache TTL: 604800
LiteSpeed Cache Database Optimization:
Post Revisions: Clean all post revisions
Auto Drafts: Clean all auto saved drafts
Trashed Posts: Clean all trashed posts and pages
Spam Comments: Clean all spam comments
Trashed Comments: Clean all trashed comments
Trackbacks/Pingbacks: Clean all trackbacks and pingbacks
Expired Transients: Clean expired transient options
All Transients: Clean all transient options
Optimize Tables: Optimize all tables in your database
Clean CSS/JS Optimizer: Purge all and clean all minified/combined CSS/JS data
LiteSpeed Cache Toolbox:
Purge Front Page: This will Purge Front Page only
Purge Pages: This will Purge Pages only
Purge 403 Error: Purge error pages, including 403 pages
Purge 404 Error: Purge error pages, including 404 pages
Purge 500 Error: Purge error pages, including 500 pages
Purge All – LSCache: Purge the LiteSpeed cache entries created by this plugin
Purge All – CSS/JS Cache: This will purge all minified/combined CSS/JS entries only
Purge All – Object Cache: Purge all the object caches
Purge All – Opcode Cache: Reset the entire opcode cache
Purge All: Purge the cache entries created by this plugin except for Critical CSS & LQIP caches
Empty Entire Cache: Clears all cache entries related to this site, including other web applications. This action should only be used if things are cached incorrectly.
3、Cloudflare CDN Settings
Click the ‘Speed’ section, click the Optimization tab, turn Auto Minify on, toggle the Brotli switch to On.
Click the ‘Caching’ section, click the Configuration tab. Under Browser Cache TTL section, set the option to Respect Existing Headers.
Click the ‘Network’ section, toggle the HTTP/3 (with QUIC) switch to On, toggle the 0-RTT Connection Resumption switch to On, toggle the gRPC switch to On, toggle the WebSockets switch to On.
4、LiteSpeed Cache Load Testing (OpenLiteSpeed Web Server)
Load Testing Tool: loader.io
Load Testing Type: Clients per second and Maintain client load
Twenty Twenty-One theme
Use “FakerPress” plugin to generate 300 posts and 1500 comments.
4.1 Download the verification file
4.2 Upload the verification file. When use DigitalOcean’s One-Click OpenLiteSpeed WordPress, the verification file of loader.io need to be uploaded to /var/www/html
4.3 Click “Verify” button, shows “Congrats, target verification passed!”
Load Test after enable LiteSpeed Cache (OpenLiteSpeed Web Server)
250 clients per second in 1 minute, the average response time is 21 ms.
500 clients per second in 1 minute, the average response time is 21 ms.
750 clients per second in 1 minute, the average response time is 21 ms.
1000 clients per second in 1 minute, the average response time is 21 ms.
1500 clients per second in 1 minute, the average response time is 21 ms.
2000 clients per second in 1 minute, the average response time is 21 ms.
2500 clients per second in 1 minute, the average response time is 22 ms.
3500 clients per second in 1 minute, the average response time is 17 ms.
4500 clients per second in 1 minute, the average response time is 17 ms.
5500 clients per second in 1 minute, the average response time is 18 ms.
6500 clients per second in 1 minute, the average response time is 20 ms.
7500 clients per second in 1 minute, the average response time is 1165 ms.
8500 clients per second in 1 minute, the test was aborted because it reached the error threshold.
Load Test (Maintain client load) after enable LiteSpeed Cache (OpenLiteSpeed Web Server)
From 0 to 250 clients in 1 minute, the average response time is 20 ms.
From 0 to 350 clients in 1 minute, the average response time is 26 ms.
From 0 to 450 clients in 1 minute, the average response time is 35 ms.
From 0 to 500 clients in 1 minute, the test was aborted because it reached the error threshold.
Note:Depending on the blog environment (plugins and various settings ), the load testing results will vary.
Speed Tests Results
The speed optimization method can be summarized as: LiteSpeed Cache plugin + Cloudflare CDN
If you have any questions, please leave me a comment.