Redis
Redis (Remote Dictionary Server) is a high-performance object cache that makes your website faster. Instead of reading data from disk like a standard database (e.g. MySQL), Redis stores frequently accessed data directly in the server's RAM — which is significantly faster.
Benefits
- Faster load times — Redis remembers previous database queries, so your server has less work to do.
- Handles high traffic — Acts as a buffer, letting your site serve more simultaneous visitors without crashing.
- Better user experience — Features like shopping carts, user sessions, and live notifications run smoother and faster.
Enable Redis
- Log in to your OS Cloud panel.
- Scroll down to the Developer Tools section.
- Locate the Redis block.
- Toggle the slider to On.
Once enabled, Redis will start running automatically inside your PHP container.
Connect Redis to WordPress
- Log in to WordPress, go to Plugins, search for Redis Object Cache, and install it.
- In WordPress, go to Settings → Redis.
- Click Enable Object Cache.
- In your
wp-config.phpfile, add the following. Replacemy_unique_site_namewith a custom name (or leave it as-is):
php
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
// Optional: give this site a unique prefix if you run multiple sites
define( 'WP_CACHE_KEY_SALT', 'my_unique_site_name' ); After activating Redis, you may briefly see a 502: Bad Gateway error. This usually means the Redis configuration hasn't fully connected to the application server yet. Fix it by restarting your PHP container: go to Advanced → Developer Tools and click the first Restart button under PHP.
Tuning Redis
Once enabled, Redis runs with default settings. Fine-tuning the configuration keeps Redis fast while staying within your container's resource limits. The configuration below is a recommended best-practice setup, optimised for stability and performance in a containerised environment.
You can copy and paste this directly into your redis.conf file:
conf
bind 127.0.0.1
protected-mode yes
maxmemory 192mb
maxmemory-policy allkeys-lru
save ""
appendonly no
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
tcp-keepalive 300
timeout 0 Only adjust these values if you know what you're doing. Incorrect settings may cause Redis to stop working or perform poorly.
