Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Wordpress

WordPress: Enable Object Caching with Redis for 10x Performance

- 22.03.26 - ErcanOPAK

πŸš€ Database Queries: 100 β†’ 5

Every page load = 100 database queries. Redis caches them in memory. Page generation: 800ms β†’ 80ms.

What Is Object Caching?

WordPress queries database repeatedly for same data (user info, settings, post meta). Object cache stores results in RAM for instant retrieval.

πŸ”„ Without Object Cache

Page Load Request:
1. Query database for site options (10 queries)
2. Query for user data (5 queries)
3. Query for post meta (20 queries)
4. Query for taxonomies (15 queries)
5. Query for widgets (10 queries)
... 100+ total queries

Every. Single. Page. Load.
Result: Slow, DB overload

βœ… With Redis Object Cache

First Page Load:
- Queries database (100 queries)
- Stores results in Redis (in RAM)

Next 999 Page Loads:
- Gets cached data from Redis (5 queries)
- Database barely used

Result: 10x faster, 95% less DB load

Setup Redis Object Cache

Step 1: Install Redis

# Ubuntu/Debian
sudo apt-get install redis-server
sudo systemctl start redis
sudo systemctl enable redis

# Verify
redis-cli ping
# Should return: PONG

Step 2: Install WordPress Plugin

Install “Redis Object Cache” plugin by Till KrΓΌss

Plugins β†’ Add New β†’ Search “Redis Object Cache” β†’ Install & Activate

Step 3: Configure wp-config.php

// Add to wp-config.php (before 'That's all, stop editing!')

define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_TIMEOUT', 1);
define('WP_REDIS_READ_TIMEOUT', 1);
define('WP_REDIS_DATABASE', 0);

// Optional: Password protection
// define('WP_REDIS_PASSWORD', 'your-redis-password');

Step 4: Enable Object Cache

Settings β†’ Redis β†’ Click “Enable Object Cache”

Status should show “Connected”

Performance Impact

Metric Without Redis With Redis Improvement
DB Queries per Page 100-150 5-10 95% reduction
Page Generation Time 800ms 80ms 10x faster
Server Load (CPU) High Low 70% less
Concurrent Users 50 500+ 10x scale

⚠️ Important Notes

  • Flush cache: After theme/plugin updates, flush Redis cache
  • Memory limit: Redis stores in RAM. Monitor memory usage
  • Persistence: Configure Redis persistence for production
  • Security: Set Redis password, bind to localhost only

“WooCommerce site was dying under 100 concurrent users. Enabled Redis object cache. Now handles 500+ users. Database queries dropped 95%. Server costs cut in half.”

β€” WordPress Performance Engineer

Related posts:

WordPress Media Library Becomes Unusable Over Time

WordPress REST API Returns 401 Only in Production

WordPress Media URLs Break After Migration

Post Views: 4

Post navigation

WordPress: Create Custom Post Types for Portfolios, Products, Reviews
Kubernetes: Use ConfigMaps and Secrets to Separate Configuration from Code

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (751)
  • Add Constraint to SQL Table to ensure email contains @ (578)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (564)
  • Average of all values in a column that are not zero in SQL (531)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (489)
  • Find numbers with more than two decimal places in SQL (447)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (751)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com