5

I am trying to understand what the role of Memcache is. A few of my friends who have been working with Drupal for more than a year tell me that Memcache would only work for logged in users, and I would have to look to Varnish or Boost for caching the content shown to anonymous users.

While I understand that varnish acts as a reverse proxy, and caches a copy of the page, I wanted to know if anonymous users make a request, and if varnish does not have a cached copy of it, would the webserver route the request to Memcache, or would the request directly go to the database?

Architecture example: Varnish/Boost, web server, Memcache, database.

8

In short, yes memcached will benefit both anonymous and authenticated visitors (even if you also use Varnish).

Memcached and Varnish operate at different layers. Varnish caches entire HTTP requests (and sometimes edge-side includes, but this is less common in the Drupal ecosystem). Memcached stores frequently used data within the application, and it is a replacement for the cache_* family of database tables.

Memcached will speed up anonymous requests when the Varnish cache misses or is bypassed.

  • Dylan, thank you for replying. The problem though is, I am not able understand if memcache is caching properly. Am I supposed to do anything specific other than install memcache, set the cache_inc property to the memcache.inc file and give the server address and port number for memcache?? – macha Jan 12 '12 at 1:34
  • 1
    @macha: Install the memcache_admin module, it will display a memcache statistics report on which you can see if memcache is used or not. – Berdir Jan 12 '12 at 9:29
1

What memcache adds to the mix is in it's name. "Memory caching". That is, instead of writing certain cachebins to database and disc, it keeps a volatile cache in RAM. This makes both reading and writing much faster, but you also loose the cache in cache of, say a server reboot.

This certainly can help either, or both, or anonymous and authenticated users, but whether or not it does comes down to what you cache, which users use what data, and what cache bins you move to memcache.

  • Letharion, thank you for the comment, but when you say it comes down to "what you cache", my question is do we have to cache explicitly or does drupal cache everything for us?? – macha Jan 12 '12 at 16:17
  • By default, most of the caching done by Drupal is for anonymous users only. There are a number of modules that will change how that works. I use Panels for controlling cache setup. – Letharion Jan 12 '12 at 19:02
  • So do you cache the panels all together?? – macha Jan 12 '12 at 19:57
  • I'm not sure I understand the question. Yes, some pages are cached in their entirety, when the situation allows. Sometimes that's not the case, and more fine-grained control is necessary. – Letharion Jan 12 '12 at 20:22

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.