What does Drupal use for caching? Is this something like APC or memcache? Where does it store cache files?

  • Hello, and welcome to Drupal Answers. When the question is not specific for a Drupal version, don't add any version tag. Differently, we should add a new version tag each time a new Drupal version is released. – kiamlaluno Dec 19 '12 at 9:27

Out of the box, it's stored in the database, in a number of tables names cache_[name_of_bin].

There are lots of other options if one wants to configure it differently.

  1. Memcache
  2. MongoDB A nice feature is that mongo supports replication across multiple databases
  3. APC
  4. Varnish Doesn't replace normal caching, but integrates with Varnish so Varnish can invalidate cache when Drupal does
  5. Boost Can generate static HTML files from content.

Also see Lullabots Beginners guide to caching data in drupal 7 (Thanks Chapabu!).

|improve this answer|||||
  • Thank you so much for the links, but I didn't totally understand what you mean by database. you mean drupal stores cache files in database? – Zim3r Dec 19 '12 at 9:28
  • 2
    Just as a side note, this is REALLY useful if you are looking to utilise the core Drupal caching system in your own modules :) – Chapabu Dec 19 '12 at 9:29
  • @Zim3r It stores strings in the database. See cache_set(). The Drupal 7 version of the code is more generic, but by default it saves the cached data in database tables. – kiamlaluno Dec 19 '12 at 9:30
  • 2
    @Zim3r Drupal doesn't create cache files, it creates cache tables in the database. If you play around with a site for a bit, and then look at the database, you will see a few new tables called cache_XYZ - have a look inside these to see how the data is stored :) – Chapabu Dec 19 '12 at 9:30
  • 2
    Replacing one, two or more, potentially complex queries with a simple one is still an improvement, and it's the easiest way to get an out-of-the-box solution. D8 could support files well ootb as well. High performance requirements is an reason to use something other than the DB. Speculations as to which is the fastest during different circumstances is a complex topic, and in my experience rarely as easy as it seems, so I'll leave that for another discussion. :) – Letharion Dec 19 '12 at 9:45

The basic drupal caching uses serialized data stored in database for caching.

If you want to have a look at the tables SHOW TABLES LIKE 'cache_%'; to get a list of all the tables associated basic drupal caching.

If you want use caching in your module code then have a look at cache_get and cache_set functions.

Drupal also has support for APC and memcached by using those respective modules.

|improve this answer|||||

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.