Front End cache errors with Memcached

XxUnkn0wnxX

Active member
Hi, i recently installed and configured Memcached,

this was my current config for frontend caching:

Code:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array(
                                        'caching'                      => true,
                                        'automatic_serialization'      => true,
                                        'lifetime'                      => 10800,
                                        'cache_id_prefix' => 'xf');

but since i started using memcached:

Code:
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => '127.0.0.1',
          
            // memcached port
            'port' => 11211,
          
            'weight' => 1,
        )
    )
);

i get this error when i load my page:

Code:
An exception occurred: The memcache extension must be loaded for using this backend ! in /home/Admin/public_html/forums/library/Zend/Cache.php on line 209

    Zend_Cache::throwException() in Zend/Cache/Backend/Memcached.php at line 123
    Zend_Cache_Backend_Memcached->__construct() in Zend/Cache.php at line 153
    Zend_Cache::_makeBackend() in Zend/Cache.php at line 94
    Zend_Cache::factory() in XenForo/Application.php at line 763
    XenForo_Application->loadCache() in XenForo/Application.php at line 973
    XenForo_Application->lazyLoad() in XenForo/Application.php at line 1004
    XenForo_Application::get() in XenForo/Application.php at line 1672
    XenForo_Application::getCache() in XenForo/Model.php at line 146
    XenForo_Model->_getCache() in XenForo/Model/DataRegistry.php at line 81
    XenForo_Model_DataRegistry->getMulti() in XenForo/Dependencies/Abstract.php at line 147
    XenForo_Dependencies_Abstract->preLoadData() in XenForo/FrontController.php at line 127
    XenForo_FrontController->run() in /home/Admin/public_html/forums/admin.php at line 13

i did also disable all plugins with $config['enableListeners'] = false;

and i have about 50+ pages full errors:

Code:
Zend_Cache_Exception: The memcache extension must be loaded for using this backend ! - library/Zend/Cache.php:209
Generated By: Unknown Account, 6 minutes ago
Stack Trace

#0 /home/Admin/public_html/forums/library/Zend/Cache/Backend/Memcached.php(123): Zend_Cache::throwException('The memcache ex...')
#1 /home/Admin/public_html/forums/library/Zend/Cache.php(153): Zend_Cache_Backend_Memcached->__construct(Array)
#2 /home/Admin/public_html/forums/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Memcached', Array, false, false)
#3 /home/Admin/public_html/forums/library/XenForo/Application.php(763): Zend_Cache::factory('Core', 'Memcached', Array, Array)
#4 /home/Admin/public_html/forums/library/XenForo/Application.php(973): XenForo_Application->loadCache(Object(Zend_Config))
#5 /home/Admin/public_html/forums/library/XenForo/Application.php(1004): XenForo_Application->lazyLoad('cache', NULL)
#6 /home/Admin/public_html/forums/library/XenForo/Application.php(1672): XenForo_Application::get('cache')
#7 /home/Admin/public_html/forums/library/XenForo/Model.php(146): XenForo_Application::getCache()
#8 /home/Admin/public_html/forums/library/XenForo/Model/DataRegistry.php(81): XenForo_Model->_getCache(true)
#9 /home/Admin/public_html/forums/library/XenForo/Dependencies/Abstract.php(147): XenForo_Model_DataRegistry->getMulti(Array)
#10 /home/Admin/public_html/forums/library/XenForo/FrontController.php(127): XenForo_Dependencies_Abstract->preLoadData()
#11 /home/Admin/public_html/forums/index.php(13): XenForo_FrontController->run()
#12 {main}

Request State

array(3) {
  ["url"] => string(53) "https://portalcentric.net/forums/index.php?liveupdate"
  ["_GET"] => array(1) {
    ["liveupdate"] => string(0) ""
  }
  ["_POST"] => array(4) {
    ["_xfRequestUri"] => string(40) "/forums/search/984952/?q=dlc&o=relevance"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
  }
}

page loads fine without front end caching, any way to make it work with both? + even when i disable memcached front end cache only works with:

Code:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';

if i try to use the array method it fails
 
Can you confirm you have the memcached.so file in /usr/lib/php/20151012/ ?

Also that it is being loaded in php.ini ?

It appears to be installed and configured, but just not loaded into PHP when it starts.

On my server I have a file - /etc/php/7.0/mods-available/memcached.ini - with content:
extension=memcached.so

Hope that helps point you in the right direction. (y)
 
Can you confirm you have the memcached.so file in /usr/lib/php/20151012/ ?

Also that it is being loaded in php.ini ?

umm yes as you can see here: https://portalcentric.net/testphpcode/phpinfo.php

Screen Shot 2017-05-23 at 12.17.45 pm.webp

It appears to be installed and configured, but just not loaded into PHP when it starts.

On my server I have a file - /etc/php/7.0/mods-available/memcached.ini - with content:
extension=memcached.so

Hope that helps point you in the right direction. (y)

since i am on Centos 6.9 using Cpanel setup all my php gets stored here: /opt/cpanel/ea-php70/root

/opt/cpanel/ea-php70/root/etc/php.ini

and all ini files also get loaded from here:

/opt/cpanel/ea-php70/root/etc/php.d

Screen Shot 2017-05-23 at 12.22.24 pm.webp

the issues i am having is front end cache atm, backend with memecached works fine.

but since i started using new backend cache, frontend cache gives me either error or blank page...

i want

Code:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array(
                                        'caching'                      => true,
                                        'automatic_serialization'      => true,
                                        'lifetime'                      => 10800,
                                        'cache_id_prefix' => 'xf');

this to work but it breaks xenforo if memcached is enabled as backend...
 
Last edited:
Your site works fine here
Make sure your browser cache is empty

yes because i don't have

Code:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array(
                                        'caching'                      => true,
                                        'automatic_serialization'      => true,
                                        'lifetime'                      => 10800,
                                        'cache_id_prefix' => 'xf');
in the config file atm..

and i get this when i put the above code in config.php

Code:
An exception occurred: The memcache extension must be loaded for using this backend ! in /home/unkn0wn/public_html/forums/library/Zend/Cache.php on line 209

    Zend_Cache::throwException() in Zend/Cache/Backend/Memcached.php at line 123
    Zend_Cache_Backend_Memcached->__construct() in Zend/Cache.php at line 153
    Zend_Cache::_makeBackend() in Zend/Cache.php at line 94
    Zend_Cache::factory() in XenForo/Application.php at line 763
    XenForo_Application->loadCache() in XenForo/Application.php at line 973
    XenForo_Application->lazyLoad() in XenForo/Application.php at line 1004
    XenForo_Application::get() in XenForo/Application.php at line 1672
    XenForo_Application::getCache() in XenForo/Model.php at line 146
    XenForo_Model->_getCache() in XenForo/Model/DataRegistry.php at line 81
    XenForo_Model_DataRegistry->getMulti() in XenForo/Dependencies/Abstract.php at line 147
    XenForo_Dependencies_Abstract->preLoadData() in XenForo/FrontController.php at line 127
    XenForo_FrontController->run() in /home/Admin/public_html/forums/index.php at line 13

from the output i am reading, when frontend is enabled, backend memcached turns off
 
Last edited:
The memcache extension must be loaded for using this backend
Make sure it's in your php.ini and it's also loaded, too. Sometimes yum/apt will take care of this for you, sometimes it won't. Make sure it's loaded in php.ini, then restart PHP.
 
it is, i'm very sure its being loaded, otherwise i would not be able to login as all my session data is being stored there.

Code:
root@server [/]# php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
enchant
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imagick
imap
intl
json
ldap
libxml
mbstring
mcrypt
memcached
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
pspell
readline
Reflection
session
shmop
SimpleXML
snmp
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]

these are all the current modules being loaded...
 
I found that I needed both PECL's loaded for it to work.. but I changed over to using Libmemcached instead before I started using Redis.
 
just noticed, and its a nuance more or less, doesn't happen on chrome though. on firefox for some reason when i uninstall or install a plugin and it does run-deferred it logs me out of admin, and when i login again only then it continues run-deferred, every time i do this when ever run-deferred is invoked this includes cache rebuilding to.
 
just noticed, and its a nuance more or less, doesn't happen on chrome though. on firefox for some reason when i uninstall or install a plugin and it does run-deferred it logs me out of admin, and when i login again only then it continues run-deferred, every time i do this when ever run-deferred is invoked this includes cache rebuilding to.
Disable all plugins that you may be using in Firefox.
And make sure that your site cannot be reached via WWW and non-WWW both.
I'm putting my money on a plugin with Firefox causing the issue - but also be sure to clear your Firefox cache (most likely not it).
 
well anything related to www subdomain is in my htaccess file:

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?portalcentric.net [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?duckduckgo.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bing.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yahoo.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?xenforo.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?twitter.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?netdna-cdn.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?maxcdn.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?cloudflare.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|bmp|tiff|pic|mp3|doc|xls|mpeg|mpg|ram|rm|wma|wav|asx|wmv|avi|mov|zip|rar|exe)$ http://oi41.tinypic.com/2wq73lx.jpg [NC,R,L]

but this is to help combat hotlinks, unsure to to edit it though since i found this code somewhere on the net...
 
Why would you need memcache module installed to use memcached ? Seems like a bug in Xenforo since the config is: $config['cache']['backend'] = 'Memcached';
Really don't remember why it was necessary to tell you the truth, just that it was on my server setup. As I said, it was resolved by using Libmemcached and then eventually Redis. Since I'm no longer running any forums and only have my blog on shared hosting I don't have the resources currently to test it (my 3 home servers are set up for a Windows AD environment for some testing currently.
 
ye i had to install both memcache & memcached, xenforo staff should work on trying to fix this to just use memcached instead...
 
ye i had to install both memcache & memcached, xenforo staff should work on trying to fix this to just use memcached instead...
memcached is the server - the memcache PHP module provides an interface to the memcached server (no 'd' at the end of the PHP module name), and libmemcached is a C/C++ client library and tools for the memcached server.

They are different things and the XF staff have already provided a way to use them ... it's just that some people get confused with what they need to install / enabled / configure and become frustrated in the process.

Install the memcached server first, get the daemon running, check it is responding on its port for localhost - then the rest should be pretty straight forward. (y)
 
Back
Top Bottom