Guest page caching

I also having the same problem. My php version is 7.4, I also checked the problem in php 7.3, 7.2, 7.1, 7.0.
My hosting provider is runcloud.
 
We have done a few tests in the meantime and attribute the problem to Redis.
First we tested the XFs disk cache where the problem no longer occurred.
We are now using Memcache and there is no longer a problem with PageCache.
 
We have done a few tests in the meantime and attribute the problem to Redis.
First we tested the XFs disk cache where the problem no longer occurred.
We are now using Memcache and there is no longer a problem with PageCache.
I have tried all three Redis, Memcached and Filesystem cache, and problem occurring in all of them.

Can you provide the full config code used for memcached and disk cache
 
I remember trying that too and the problem still occurred on Memcache too.

Completely without Redis, and only Memcached, there are no more problems here.

Code:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'Memcached';
$config['cache']['config'] = [
    'server' => '127.0.0.1'
];
 
$config['cache']['enabled'] = true; $config['cache']['provider'] = 'Memcached'; $config['cache']['config'] = [ 'server' => '127.0.0.1' ];

I think this code will not enable guest page caching. I am talking about guest page caching with memcached or filesystem or redis.
 
Completely without Redis, and only Memcached, there are no more problems here.

Code:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'Memcached';
$config['cache']['config'] = [
    'server' => '127.0.0.1'
];

you need something like this code to enable guest page cache with memcached:

PHP:
$config['cache']['enabled'] = true;
$config['pageCache']['enabled'] = true;
$config['cache']['context']['page']['provider'] = 'Memcached';
$config['cache']['context']['page']['config'] = [
        'host' => '127.0.0.1',
        'port' => 6379,
        'database' => 4
        ];

And the problem exists with this code.
 
I have tried all three Redis, Memcached and Filesystem cache, and problem occurring in all of them.

Can you provide the full config code used for memcached and disk cache

Here my old Config for FileSystemCache:
Code:
$config['cache']['enabled'] =  true;
$config['cache']['provider'] = 'Filesystem';
$config['cache']['config'] = ['directory' => '/var/www/vhosts/mydomain.tld/httpdocs/internal_data/xenforo-cache']; // fullpath must exist!
$config['cache']['registry'] = true;
$config['cache']['sessions'] = true;
$config['cache']['css']['enabled'] = true;
// guest page cache
$config['pageCache']['enabled'] = true;
$config['pageCache']['provider'] = 'Filesystem';
$config['pageCache']['config'] = ['directory' => '/var/www/vhosts/mydomain.tld/httpdocs/internal_data/xenforo-cache'];
$config['pageCache']['lifetime'] = 300;
$config['pageCache']['recordSessionActivity'] = true;
 
Last edited:
@all You are right. The problem also occurs when using memcached or XF's hard disk cache.

For me here, however, not when I use Firefox72.0.1 (64-Bit), but only with Chrome( Version 79.0.3945.117). My (test) error Sorry for that.
 
Last edited:
Interesting. I'm going to see if I can recreate this tomorrow if I get a chance on a different server with a base install. If I can hopefully it will aid in one of us getting to the bottom of this for @JoyFreak

I think I figured out this guest cache 304 thing for me at least. I'm using Cloudflare to guest cache my pages. So not using Xenforo's system.

In Chrome/Firefox, when I logout, I get what looks like a Logged in page. As stated, this is because a 304 response from Cloudflare, not from Xenforo. I'm bypassing cache based on the xf_lscxf_logged_in cookie (amongst others)

What's happening:

1. Log in -> xf_lscxf_logged_in cookie set
2. Bypass Cloudflare cache on all pages b/c of xf_lscxf_logged_in cookie
3. Log out -> xf_lscxf_logged_in removed, you are considered a Guest and sent to main forum home
4. Cloudflare thinks you are a normal guest, checks it's cache and it hasn't changed, so it sends you a 304 -- not knowing that your browser's cache is outdated. Browser, shows you logged in, since that is cached locally on your computer.

My quick solution is:

Add a new cache bypass cookie "mr_logged_out" to Cloudflare
Ideally, when logging out, set a "mr_logged_out=1" session cookie
Now when you are sent to the forum home, Cloudflare bypasses its cache and serves a fresh (logged out) page, instead of telling your browser to deliver what it has cached

I've tested it by giving everyone logged in a "mr_logged_out" session cookie (explicitly set a cookie via js for all logged in users in helper_js-global - see code below). So when you logout, you will be bypassing the cache (for the rest of that browser session). Ideally, this cookie would only be set upon logout, but that would require a small add-on.

Anyone test and see if that works for you?

arn

Code:
    <xf:if is="$xf.visitor.user_id">
<script>
    function mr_setCookie(name,value,days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        expires = "; expires=" + date.toUTCString();
    }
    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
}

mr_setCookie("mr_logged_out","1","")

</script>
    </xf:if>
 
Last edited:
If anyone has a consistent reproduction case they are more than welcome, as ever, to submit a ticket with those details. Perhaps even the very customer you speak of absolutely should enable it and they can then report the issue to us if they do encounter it.
I did submit a support ticket some time ago about this, but I don't think it was seriously being looked at. They pointed me to this thread.
The situation is reproducible on a clean XF 2.1 install without add-ons.

Tried with redis and filecache, same problem: after logout a status 304 page is served.
Although this is a server side problem, it only happens when guest page cache is on.
Any other thoughts about this?
 
Last edited:
I did submit a support ticket some time ago about this, but I don't think it was seriously being looked at. They pointed me to this thread.
The situation is reproducible on a clean XF 2.1 install without add-ons.

Tried with redis and filecache, same problem: after logout a status 304 page is served.
Although this is a server side problem, it only happens when guest page cache is on.
Any other thoughts about this?

Did you try my solution above?

arn
 
this will prevent Apache from returning a 304. And it might help. This isn't probably the best long term solution, but will narrow it down

Cloudflare, Nginx etc ... I don't like that. Here is a highly optimized SQL server and an Apache 2.4.x with http2 and Brotli that's enough.

I hope there is no crawler DDos with this header. ;)
I'm going to test this now and see the disadvantages. The logout, also with PageCache, apparently now works as it should.
 
Last edited:
Top Bottom