XF 2.2 Disable Exclude Cache pages for guests at Page - Node Level ?

ProCom

Well-known member
We're really liking the ability to "Cache pages for guests". It's a fantastic feature and seems to be incredibly effective.

One thing we're dealing with is that we have one "page" that we would like to NOT be cached by this system.

Is there any way to disable Cache pages for guests at a page or node level?

All I could find when searching were these two threads:


... but they seemed specific to widgets and the instructions for implementation were unfortunately over my head and/or not specific enough.

Thanks in advance for any tips on removing guest caching for specific pages / nodes !
 
If it's just a few specific URLs you could do smth. like
PHP:
$config['pageCache']['enabled'] = (!isset($_SERVER['REQUEST_URI']) || !in_array($_SERVER['REQUEST_URI], ['/pages/somepage/', '/some/other/url?param=1']));
in config.php without an Add-on.

But if you need more complex conditions, you'd need an Add-on.
 
Last edited:
If it's just a few specific URLs you could do smth. like
PHP:
$config['pageCache']['enabled'] = (!isset($_SERVER['REQUEST_URI']) || !in_array($_SERVER['REQUEST_URI], ['/pages/somepage/', '/some/other/url?param=1']));
in config.php without an Add-on.

But if you need more complex conditions, you'd need an Add-on.
@Kirby thank you for this idea!!!

...but for the sake of argument, let's say I'm a coding newb ;)

I'm guessing that code goes in my config.php file? Does it replace the line "$config['pageCache']['enabled'] = true;", or something else?

In my current config.php
Code:
// Cache pages for guests
$config['pageCache']['enabled'] = false;
$config['pageCache']['lifetime'] = 60;
$config['cache']['context']['page']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['context']['page']['config']  = array(
        'server' => '123.456.78',
        'port' => 1234,
        'compress_data' => 6,
        'database' => 1,
        'serializer' => 'igbinary',
    );

I attempted it with my home page, swapping out the first config line with this code:

Code:
$config['pageCache']['enabled'] = (!isset($_SERVER['REQUEST_URI']) || !in_array($_SERVER['REQUEST_URI], ['/pages/home/']));

... and got a 500 server error :(
 
Back
Top Bottom