[bd] Cache [Deleted]

It seems like the view count is possibly not updating when cached? I'm getting stats of 40,000 page views from my clicky.com monitoring for the thread, but only 11,000 reported in XF

Contrails and Chemtrails | Metabunk 2014-01-30 22-18-52.webp
(441) metabunk.org » Dashboard | Clicky 2014-01-30 22-18-19.webp
 
Today I had a thread that was very popular that illustrates what happens when the cache kicks in. I posted it, and immediate traffic started to steadily climb, with the graph below representing around 10,000 guests looking at the page. CPU load steadily climbed until the second page was reached, then the cache kicked in, and it dropped back to much more manageable levels, even though there was no let-up in the growth
View attachment 66138
So:
  1. Well done, the cache worked great!
  2. It would have been great to have the option to switch on caching threads with one page :) I actually made some posts just to kick it over onto the next page.
One thread can put server load from 0.1 to 0.5? That's one hell of a thread :) And yes, caching the page will affect the views.
 
One thread can put server load from 0.1 to 0.5? That's one hell of a thread :) And yes, caching the page will affect the views.
It was an unusually popular thread. However my forum gets these spikes every few weeks, and my goal here is to prevent slowdown or outages during those spikes. Your add-in is great for that, so long as the thread has more than a page.

View count is not a huge deal, but would certainly be greatly appreciated, as otherwise the view counts become meaningless. Maybe an option, as it's a bit of a speed trade-off?
 
It was an unusually popular thread. However my forum gets these spikes every few weeks, and my goal here is to prevent slowdown or outages during those spikes. Your add-in is great for that, so long as the thread has more than a page.

View count is not a huge deal, but would certainly be greatly appreciated, as otherwise the view counts become meaningless. Maybe an option, as it's a bit of a speed trade-off?
I will see what I can do.
 
There is now a CSRF token generated attached to sessions so it can be used for guests. It's (only) used for Google+ logins (as per their integration documentation). If you're caching pages, the CSRF token wouldn't be correct for each user.

It won't be page specific; it will potentially happen whenever a cached page is served.
 
There is now a CSRF token generated attached to sessions so it can be used for guests. It's (only) used for Google+ logins (as per their integration documentation). If you're caching pages, the CSRF token wouldn't be correct for each user.

It won't be page specific; it will potentially happen whenever a cached page is served.
Thanks Mike for the input. I will add new code to work specifically with Google+ then.
 
I've created a patch to fix the thread view counts not being updated

In bdCache/Core.php at the start of the output function (around line 148 currently), add:
PHP:
        $request = $fc->getRequest();
        $uri = $request->getRequestUri();
        // $ uri will be something like:
        // "/threads/debunked-fukashima-radiation-reaches-west-coast.2898/"
        // So we explode it into an array of parts
        $parts = explode('/', $uri);
        // only want to handle /threads/
        if ($parts[1] == 'threads')
        {
            // split into . delimited strings
            $num = (explode('.',$parts[2]));
            // we want the last one, as the name might contains dots, so can't take the second
            $tnum = end($num);
            // make sure it's a positive integer
            $threadId = intval($tnum);
            if ($threadId > 0)
            {
                // and log that view
                $threadModel = XenForo_Model::create('XenForo_Model_Thread');
                $threadModel->logThreadView($threadId);
            }
        }

I don't think this will make much difference to performance, as logThreadView just is a quick insert into the view log (the actual counting is done via cron).

It's parsing the URI to get the threadId. I'm not sure if there's a case where a thread view would not have the format "/threads/some-thread-name.1234/", but buyer beware.
 
I've created a patch to fix the thread view counts not being updated

In bdCache/Core.php at the start of the output function (around line 148 currently), add:
PHP:
        $request = $fc->getRequest();
        $uri = $request->getRequestUri();
        // $ uri will be something like:
        // "/threads/debunked-fukashima-radiation-reaches-west-coast.2898/"
        // So we explode it into an array of parts
        $parts = explode('/', $uri);
        // only want to handle /threads/
        if ($parts[1] == 'threads')
        {
            // split into . delimited strings
            $num = (explode('.',$parts[2]));
            // we want the last one, as the name might contains dots, so can't take the second
            $tnum = end($num);
            // make sure it's a positive integer
            $threadId = intval($tnum);
            if ($threadId > 0)
            {
                // and log that view
                $threadModel = XenForo_Model::create('XenForo_Model_Thread');
                $threadModel->logThreadView($threadId);
            }
        }

I don't think this will make much difference to performance, as logThreadView just is a quick insert into the view log (the actual counting is done via cron).

It's parsing the URI to get the threadId. I'm not sure if there's a case where a thread view would not have the format "/threads/some-thread-name.1234/", but buyer beware.
The new version has an option to keep thread view for cached page ;)
 
Top Bottom