1

I am noob to using both Varnish and Memcached. I have been following some copy and paste install guides.

I have both servers installed and running. Memcached seems to be working fine. Varnish is serving pages but there are a lot of cache misses. I am trying to enable the Drupal module to make Varnish aware to cache the pages, the css etc.

However, when I copy the settings.php snippet from the README.txt file in the Varnish module to my own settings.php I get a white page and this message in the Apache error log:

PHP Fatal error:  Class 'MemCacheDrupal' not found in /var/www/myhost/includes/cache.inc on line 31

Here is the cache section added to my settings.php. The Varnish part is commented out because it causes the above error with MemCached.

# Memcache
$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
// The 'cache_form' bin must be assigned no non-volatile storage.
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_key_prefix'] = 'myhost';
# Varnish
// Add Varnish as the page cache handler.
#$conf['cache_backends'][] = array('sites/all/modules/contrib/varnish/varnish.cache.inc');
#$conf['cache_class_cache_page'] = 'VarnishCache';
// Drupal 7 does not cache pages when we invoke hooks during bootstrap.
// This needs to be disabled.
#$conf['page_cache_invoke_hooks'] = FALSE;

What is wrong with the Varnish snippet or with my setup in general?

I tried re-ordering to put the Varnish lines before the Memcached lines and I got this error:

PHP Fatal error:  require_once(): Failed opening required '/var/www/myhost/Array' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/myhost/includes/bootstrap.inc on line 2308
3

I got it a little bit later. It was just the array format being different in the two sources I copies and pasted from. The problem line was:

#$conf['cache_backends'][] = array('sites/all/modules/contrib/varnish/varnish.cache.inc');

It should be:

#$conf['cache_backends'][] = 'sites/all/modules/contrib/varnish/varnish.cache.inc';
0

I was in the same issue and my "solution" was to change the order settings without changing the line that was your solution as:

  1. Varnish
  2. Memcache

My settings (Drupal 7.34, Varnish 3, Memcache 3.8.0):

// Varnish
// Add Varnish as a cache bin.
$conf['cache_backends'] = array('sites/all/modules/contrib/varnish/varnish.cache.inc');

//If you plan to use the expire module to be selective with your cache clearing you should add as a new cache bin.

//$conf['cache_class_external_varnish_page'] = 'VarnishCache';

// If you are not going to use the expire module you should replace the default pagecache with varnish.

$conf['cache_class_cache_page'] = 'VarnishCache';

// Memcache
$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['lock_inc'] = 'sites/all/modules/contrib/memcache/memcache-lock.inc';
$conf['memcache_stampede_protection'] = TRUE;
$conf['cache_default_class'] = 'MemCacheDrupal';

// The 'cache_form' bin must be assigned to non-volatile storage.
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

// Don't bootstrap the database when serving pages from the cache.
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;

//Note that no servers or bins are defined.  The default server and bin
//configuration which is used in this case is equivalant to setting:

$conf['memcache_servers'] = array('localhost:11211' => 'default');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.