6

Once I worked in a company that had its own CMS and we used to cache data in files so basically the system would check if the cache file existed, if not it would go to the database, get the data, save it in a file and then show it to the users (basic cache thing). This resulted in less connections to the database.

I would like to know if this is a good option to Drupal or if there is any problems with this way of caching things.

14

As anschauung mentioned you can use Boost to create a static page cache. Boost will copy the entire HTML of a page and store that HTML as a static file on the disk in a specific directory. A set of rewrite rules will cause the webserver to first look for a static HTML file for each request and serve that file if it's found. If it isn't, a normal Drupal request occurs via PHP. Requests served through the static file will be really fast, but PHP and the database are completely bypassed.

Boost is not a replacement for the cache backend and that Drupal will still use the cache tables in the database when a miss occurs on the static HTML files created by Boost. If you want to completely replace the cache backend, you could look into memcache, which stores serialized objects in memory. Memcached runs as a daemon on the server and can be connected to via TCP. This can be both a good and bad thing, depending on number of servers in the environment and

Note that it is possible to have the database keep the cache tables in memory as well (at least with MySQL), although I'm not sure about the specifics of doing so.

You could all use the APC module if you're running Drupal 7. The APC modules integrates with the APC opcode cache and uses it as Drupal's cache backend. APC can be faster than memcached in certain scenarios because there is no TCP connection overhead. Each APC cache is tied to a specific server, while memcached and the database can be shared by multiple front end servers (again, this can be good or bad).

| improve this answer | |
  • To follow on from this, cache behaviour more like memcache/APC, but with files as the storage medium (so no 3rd party software) is possible with Drupal 6 via the CacheRouter module. This is being continued in to Drupal 7 via the FileCache module, which died during Drupal 6 but is being resurrected by a new maintainer right now - both of these options are file caching but are not the model Boost uses (though I understand the Boost maintainer wants to move that way in Drupal 7, ultimately). – Greg Mar 4 '11 at 15:57
  • Thanks Greg, that's good info. Didn't know what other cache backends there were. – CalebD Mar 4 '11 at 16:26
  • In reply to Greg's answer about Boost's future (yeah I don't have enough juice to comment yet) here is the comment about a potential merge with the filecache module: groups.drupal.org/node/131639#comment-427114. Main point of something like this is to use more Drupal APIs, allow custom logic that can't be done in htaccess rules, lower the bar for adoption, & eventual option for core inclusion. A simple html file cache should be apart of core IMHO as it offers huge gains on cheap hosting. – mikeytown2 Mar 10 '11 at 10:13
7

In fact, the Boost module does exactly what you're describing -- it creates file caches of pages and re-checks the database if a particular file doesn't exist.

Give it a look :)

| improve this answer | |
2

While the Boost module accomplishes the same method, there are many alternatives that may perform even better, such as the Drupal page cache (which caches the whole page into a single database record), memcache, or even Varnish.

| 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.