Practical Redis Caching Setup for 1C-Bitrix
Standard Bitrix cache writes data to files in /bitrix/cache/. On a high-load site with 10,000 daily visitors, this generates up to 300,000 IO operations per second. If the disk is not NVMe, latency increases and pages load in 3–5 seconds. We often encounter such projects: on one e-commerce store with 50,000 products, the catalog page took 4.2 seconds to load. After replacing the file cache with Redis, the time dropped to 0.6 seconds—7 times faster, without changing component code. On average, switching from file cache to Redis saves $200 per month on server costs for a site with 10,000 daily visitors. Server infrastructure savings can reach 50% by reducing disk subsystem load. As noted in the 1C-Bitrix documentation, "for high-load projects, it is critical to use in-memory caching to reduce response time"Source: 1C-Bitrix Documentation.
Why Redis Instead of File Cache?
Redis is an in-memory store with microsecond access, documented on Wikipedia. It removes load from the disk subsystem and allows caching much more data without speed loss. Redis is 100 times faster than HDD file cache for random reads. Tagged cache in Redis works more efficiently: no issues with thousands of small files.
Comparison on a typical project:
| Parameter | File Cache | Redis |
|---|---|---|
| Average access latency | 1–5 ms (HDD) / 100–500 µs (SSD) | 50–100 µs |
| Maximum requests | ~500 IOPS (HDD) | 50,000+ ops/s |
| Tagged cache storage | Small files, directory cleanup | Efficient tags, fast DEL |
| Memory consumption | Depends on FS | Controlled via maxmemory |
Setting Up Redis for Caching in 1C-Bitrix
Let's go through the step-by-step configuration.
Connecting Redis as a Cache Backend
In /bitrix/.settings.php, add or modify the cache section:
'cache' => [ 'value' => [ 'type' => [ 'class_name' => '\\Bitrix\\Main\\Data\\CacheEngineRedis', 'extension' => 'redis', ], 'sid' => 'site1', // unique prefix for data separation ], ], Redis connection settings are defined in a separate file /bitrix/php_interface/redis.php or via configuration:
// /bitrix/php_interface/init.php define('BX_CACHE_TYPE', 'redis'); define('BX_CACHE_SID', 'site1'); $GLOBALS['CACHE_REDIS'] = [ 'host' => '127.0.0.1', 'port' => 6379, 'database' => 2, // separate DB from sessions 'timeout' => 2, ]; Separating Cache and Sessions
Use different Redis databases (parameter database):
- DB 0 — service (RDB persistence)
- DB 1 — sessions
- DB 2 — Bitrix data cache
- DB 3 — HTML page cache (if used)
This allows clearing the cache independently of sessions: redis-cli -n 2 FLUSHDB clears only the data cache.
More on Redis session setup
To store sessions in Redis, add to `init.php`: ```php ini_set('session.save_handler', 'redis'); ini_set('session.save_path', 'tcp://127.0.0.1:6379?database=1&prefix=SESS_'); ``` And in the Redis configuration for sessions, use the `volatile-lru` policy: ```ini maxmemory-policy volatile-lru ```Redis Configuration for Data Cache
# /etc/redis/redis.conf bind 127.0.0.1 port 6379 maxmemory 1gb maxmemory-policy allkeys-lru # evict least recently used when memory full activerehashing yes tcp-keepalive 300 allkeys-lru is the right policy for cache: when memory fills, rarely used keys are evicted. For sessions, volatile-lru is better (evicts only keys with TTL).
Choosing Eviction Policy for Cache
Comparison of popular policies:
| Policy | Description | When to Use |
|---|---|---|
allkeys-lru |
Evicts least recently used keys among all | For data cache |
volatile-lru |
Evicts LRU among keys with TTL | For sessions |
noeviction |
Returns error when full | Only if volume is certain |
allkeys-lfu |
Evicts least frequently used | If access pattern is uneven |
For Bitrix data cache, we recommend allkeys-lru. When memory is low, old, rarely used entries are evicted while hot data remains. More on eviction policies can be found on Wikipedia.
Tagged Cache in Redis: How It Works
Bitrix uses tagged cache to invalidate groups of related data. When an infoblock item changes, the tag iblock_id_N invalidates all cache associated with that infoblock. Redis stores tags more efficiently than the file system—no issue with thousands of small files. Verify that tagged cache works:
redis-cli -n 2 KEYS "BITRIX_CACHE_TAG_*" | head -20 If there are no keys, tagged cache is not used or data is not yet cached.
Solving Low Hit Rate
Low hit rate (below 80%) indicates problems. Possible causes:
- Too frequent invalidations: for example, exchange rates change every 10 seconds. Solution—increase TTL or cache data longer.
- Small Redis volume: if 256 MB is allocated but the site generates 1 GB of cache, old keys are evicted.
- Wrong eviction policy: must be
allkeys-lrufor cache, notnoeviction.
Target hit rate is 95%+. In our projects, we use Grafana monitoring for this metric. If you want to speed up your Bitrix site, contact us—we'll conduct an audit and propose a solution.
Monitoring Cache Performance
# Usage statistics redis-cli -n 2 INFO stats | grep -E "keyspace_hits|keyspace_misses" # Hit rate = hits / (hits + misses) # Target: > 90% # Number of keys redis-cli -n 2 DBSIZE # Memory usage redis-cli INFO memory | grep used_memory_human We recommend setting alerts when hit rate drops below 85%.
Deliverables for Redis Setup Work
When ordering turnkey Redis setup, we provide:
- Audit of current configuration—check Bitrix version, PHP, Redis, performance analysis.
- Redis server preparation—installation, configuration based on load (maxmemory, eviction policy, persistence).
- Integration with Bitrix—modifying
.settings.phpandinit.php, separating cache and sessions on different databases. - Testing—measuring hit rate, page generation time before and after, verifying tagged cache.
- Documentation—configuration description, maintenance instructions, monitoring scripts.
- Training—showing how to track metrics and clear cache independently.
- Support—30 days guarantee after launch: answer questions, help with fine-tuning.
Timing—from 2 to 5 days depending on project complexity. Investment in Redis setup pays off in 1-2 months by reducing server load. We'll assess your project for free—just write to us. Order Redis setup—get an engineer consultation. We have 5 years of experience in 1C-Bitrix development, over 80 successful projects in site acceleration.

