Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save algotrader-dotcom/67e43be0659beae80c8a to your computer and use it in GitHub Desktop.
Save algotrader-dotcom/67e43be0659beae80c8a to your computer and use it in GitHub Desktop.
Drupal 7 + Memcached Storage + Nginx page cached => Faster 700%
# 1. Introduction
With page cached in memcached, nginx will serve this page cached (html render) from nginx directly to user. So it’s very fast compared to norway it does.
# 2. Requirements
Memcached storage module
# 3. Installation
For sites/default/settings.php
## Advanced usage of Drupal page cache.
$conf['cache_backends'][] = ‘sites/all/modules/memcache_storage/memcache_storage.page_cache.inc';
$conf['cache_class_cache_page'] = 'MemcacheStoragePageCache';
# Enable storing of plain HTML text instead of Drupal usual cache object.
$conf['memcache_storage_external_page_cache'] = TRUE;
For nginx conf
## Set content type for the rest requests.
default_type text/html;
## Trying to find page cache in memcached pool.
add_header X-Nginx-Page-Cache HIT;
set $memcached_key "[PREFIX]-cache_page-$scheme://$server_name$uri$is_args$args";
memcached_pass 127.0.0.1:11211; // This must be matched bin page_cache
proxy_intercept_errors on;
error_page 404 502 = @drupal;
If you didn't define $conf['memcache_storage_key_prefix'] $memcache_key will look like that:
set $memcached_key "cache_page-$scheme://$server_name$uri$is_args$args";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment