Ana içeriğe geç

Configuring Redis Cache in XenForo 2.3: Session, Page & Data Registry Optimization

Configuring Redis Cache in XenForo 2.3: Session, Page & Data Registry Optimization

Administrator
Configuring Redis Cache in XenForo 2.3: Session, Page & Data Registry Optimization
Offloading repetitive database queries into in-memory storage is one of the most effective ways to lower server load and improve response times on active XenForo 2.3 communities. By connecting XenForo's native caching layer to Redis, you can serve data registry items, compiled CSS, active user sessions, and guest HTML pages directly from RAM instead of hitting MySQL on every request.



Server Prerequisites and PHP Extension Check
Before modifying your XenForo configuration, verify that the Redis server daemon is running on your host and that the phpredis extension is enabled for your active PHP version. You can confirm both requirements via SSH by running redis-cli ping (which should return PONG) and checking php -m | grep redis. If your hosting environment does not provide the native phpredis module, you can alternatively install Xon's Redis Cache add-on, which includes a pure-PHP Credis connector.



Enabling Global Data Registry and Session Caching
Open your src/config.php file and append the core cache directives to route XenForo's global data registry and user sessions into Redis database 0:
Kod:
$config['cache']['enabled'] = true; $config['cache']['sessions'] = true; $config['cache']['provider'] = 'Redis'; $config['cache']['config'] = [ 'host' => '127.0.0.1', 'port' => 6379, 'database' => 0 ];
If your host uses a local Unix socket rather than TCP, replace the host and port lines with 'host' => '/path/to/redis.sock' and omit the port parameter. Always ensure your allocated Redis memory limit is large enough to hold active session keys so logged-in members are not unexpectedly signed out during peak traffic.



Isolating Guest Page Caching in a Separate Context
XenForo supports full-page caching for logged-out visitors, which dramatically reduces PHP execution overhead from search engine crawlers and guest traffic. Because guest HTML snapshots consume substantial RAM, assign the page cache context to a dedicated Redis database index (such as database => 1) so large page caches never evict active user sessions from the global pool:
Kod:
$config['pageCache']['enabled'] = true; $config['cache']['context']['page']['provider'] = 'Redis'; $config['cache']['context']['page']['config'] = [ 'host' => '127.0.0.1', 'port' => 6379, 'database' => 1 ];
To verify that guest page caching is working properly, open your forum in a private or incognito browser window and inspect the network response headers in Developer Tools; cached guest requests will display the X-XF-Cache-Status: HIT header.
İşin Doğrusu Youtube Kanalı

Konu ile Alakalı Benzer Konular

Zamanlanmış görev