XF 2.1 Guest page caching

JoyFreak

Well-known member
So I have this in my config already:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
'host' => '127.0.0.1',
'password' => 'Boobs!'
];


Do I just need to simply add this in the end?
$config['pageCache']['enabled'] = true;
 
i assume removing $config['cache']['provider'] = 'XXX'; should do the trick? Confirmation would be nice.

about guest page caching. i played with it using apc. noticed that the number of cached elements kept on increasing along with storage. and they did not go lower even after the caching time expired. and when the cache was full, it just reset and started from scratch.

i guess it keep on storing the cached pages permanently. and only update it on a fresh hit if the cache is old? cache would not delete on expiry by itself? this means that on a large board... you might end up with gigabytes of cached page over a long period of time?
 
i assume removing $config['cache']['provider'] = 'XXX'; should do the trick? Confirmation would be nice.

about guest page caching. i played with it using apc. noticed that the number of cached elements kept on increasing along with storage. and they did not go lower even after the caching time expired. and when the cache was full, it just reset and started from scratch.

i guess it keep on storing the cached pages permanently. and only update it on a fresh hit if the cache is old? cache would not delete on expiry by itself? this means that on a large board... you might end up with gigabytes of cached page over a long period of time?
when i used APC, yes i create my own cron job to clear cache regularly (i think i did every 1 hour).
there is an APC config called apc stat if i remember correctly, to auto purge the cache based on cache life. But it slows APC down.
So i decided to turn apc stat off, and i do cache purging by myself.
 
right. i have a low traffic forum so did not see any issues when apc got full. i was monitoring the backend and it just flushed itself and restarted caching pages.

i guess i would stick to filesystem for guest pages. my friend who manages my server is not very keen on installing memcache at the moment!
 
i assume removing $config['cache']['provider'] = 'XXX'; should do the trick? Confirmation would be nice.
Yes, this would do it (as it will then default to a "void" cache).

about guest page caching. i played with it using apc. noticed that the number of cached elements kept on increasing along with storage. and they did not go lower even after the caching time expired. and when the cache was full, it just reset and started from scratch.
That is how APC works. It doesn't use a LRU system for removing the oldest entries (ref: https://medium.com/@davidtstrauss/avoiding-the-pitfalls-of-apcu-4aa9de00ef93).
 
This is how my current 2.1 beta setup looks like:

Code:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
    'database' => 0,
    'host' => '127.0.0.1',
    'password' => 'xxxxxxxx'
  ];

$config['pageCache']['enabled'] = true;
$config['cache']['context']['page']['provider'] = 'Redis';
$config['cache']['context']['page']['config'] = [
    'database' => 1,
    'host' => '127.0.0.1',
    'password' => 'xxxxxxxxx'
  ];

So 2 different caching databases, one for regular caching and one for guest page caching.

That should do it, both Redis databases contain keys...
 
If you have a working Redis it should work. But test before you take it to production.
The reason for seperate databases is explained by @Mike :
 
The only downside of that configuration (using the same redis instance), is that you can't control memory per database, that's why Mike wrote "We would recommend a distinct caching "instance" for page caching", not database.
 
The only downside of that configuration (using the same redis instance), is that you can't control memory per database, that's why Mike wrote "We would recommend a distinct caching "instance" for page caching", not database.
can you explain more? So i should not use redis with different database for both normal caching & guest caching to avoid situation in Mike's post?
 
Last edited:
can you explain more? So i should not use redis for both normal caching & guest caching to avoid situation in Mike's post?

If you use one instance of Redis, even using different databases, you have no way to control the memory of the shared cache.
Mike explains the issue in this post: https://xenforo.com/community/threads/guest-page-caching.160116/post-1320884
You can us a mix of Redis for sessions and Memcached / Filesystem for files or two instances of Redis/Memcached running in different ports.
 
How well does the file system cache work using the guest page caching. My main is using Memcached so I would rather not use it. Is the file system caching just a matter or creating a folder and pointing the patch to it? Any drawbacks/speed doing it this way?
 
i am using it and yeah, that's how it works. i guess the only drawback would be that cached content would be loaded from the hdd/sdd on your server instead of ram? assuming memcache store the data in ram?
 
If i try to use Redis like @duderuud i get the error message "Cannot load Redis cache provider without Redis".
And i use this Add-on:

Code:
$config['pageCache']['enabled'] = true;
$config['cache']['context']['page']['provider'] = 'Redis';
$config['cache']['context']['page']['config'] = [
        'server' => '127.0.0.1',
        'port' => 6379,
        'password' => 'passwd',
        'database' => 1
        ];
 
I am using it and yeah, that's how it works. i guess the only drawback would be that cached content would be loaded from the hdd/sdd on your server instead of ram? assuming memcache store the data in ram?

In my simple tests I didn't notice any diference between Filecache and Redis/Memcache.
The real difference is between cache = true or false :)

No cache:

Code:
Running 10s test @ https://example.com/
  1 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   179.65ms   58.66ms 421.56ms   69.73%
    Req/Sec    55.47     25.27   118.00     65.31%
  554 requests in 10.07s, 27.20MB read
Requests/sec:     54.99
Transfer/sec:      2.70MB

With cache:

Code:
Running 10s test @ https://example.com/
  1 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    75.39ms   36.01ms 424.34ms   83.13%
    Req/Sec   137.04     29.75   198.00     78.57%
  1364 requests in 10.09s, 66.84MB read
Requests/sec:    135.12
Transfer/sec:      6.62MB

If i try to use Redis like @duderuud i get the error message "Cannot load Redis cache provider without Redis".
And i use this Add-on:

Code:
$config['pageCache']['enabled'] = true;
$config['cache']['context']['page']['provider'] = 'Redis';
$config['cache']['context']['page']['config'] = [
        'server' => '127.0.0.1',
        'port' => 6379,
        'password' => 'passwd',
        'database' => 1
        ];

With that configuration you're not using Xon's addon. Please see here some examples: https://xenforo.com/community/resources/redis-cache-by-xon.5562/field?field=faq

Code:
$config['cache']['provider'] = 'SV\RedisCache\Redis';

The message "Cannot load Redis cache provider without Redis" says you haven't installed php-redis I think.
 
I am aware that this is not the configuration for Xons add-on. I just wanted to say that I use Xon's add-on as Redis cache and want to activate the guest cache as well.

This configuration will cache everything in Redis on two different database using sockets with Xon's addon:

Code:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = [
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'database' => 0,
    'compress_data' => 6,
    'serializer' => 'igbinary',
    'use_lua' => true,
];

$config['pageCache']['enabled'] = true;
$config['cache']['context']['page']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['context']['page']['config'] = [
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'database' => 1,
    'compress_data' => 6,
    'serializer' => 'igbinary',
    'use_lua' => true,
];
 
Top Bottom