perusio / drupal-with-nginx

Running Drupal using nginx: an idiosyncratically crafted bleeding edge configuration.
855 stars 246 forks source link

Enable microcache options on a per-vhost basis #25

Open cweagans opened 12 years ago

cweagans commented 12 years ago

The use case that I want to fill is something like this:

All sites live in /var/www. Let's talk about example.com.

So, in /var/www, there is a directory called "example.com". Inside that directory, there are three more directories: "dev", "stage", and "prod". Each of those directories contains a complete Drupal installation. It would be very nice to only enable the microcache for the prod installation, and not dev or stage.

perusio commented 12 years ago

Hmm. You can try using something like this "micromodule" that implements hook_init() enable it and then set:

fcgi_cache_bypass $no_cache $http_x_drupal_microcache;
fcgi_no_cache $no_cache $http_x_drupal_microcache;

on the fcgi_microcache.conf file.

This is a nice idea for a very simple but useful module: thanks.

perusio commented 12 years ago

Easier. Just send the X-Accel-Expires: 0 header. I've updated the module. No need to touch any config file. Install the module and enable it. An .info file is missing though.

cweagans commented 12 years ago

Could I just hardcode the cache_bypass lines into the vhost for dev and stage? Or do I really need to have a drupal module send that header? I want to skip the cache unconditionally for dev and staging, so it doesn't make a lot of sense to me to add another module to just those environments.

perusio commented 12 years ago

AFAICT the easiest way is for you to add:

add_header X-Accel-Expires 0;

in the index.php location. Or more simply just comment out the include sites-available/microcache_fcgi.conf line :)