Baby Day! (Act I)

2.9.12 - 11:45pm Jenny wakes me up with, “I think my water broke!” I groggily look over at her and ask, “Are you sure?” “Yeah, pretty sure”, she says. “What time is it?” I ask her. “11:45”. “What? Uhg.” I had gotten about two and a half hours of sleep by this time, having gone to bed early to try and kick my oncoming head cold. “Did you call Katie?” Katie is our birthing companion, whom we took HypnoBirthing courses with months earlier. “I am going to now”, Jenny tells me. “Do you want to go to the hospital?” “No, let’s just see what happens. Go back to sleep.” I promptly fall back asleep, but hear her stirrings through dreams of a strange birth in which the baby is born in a tub and no one at the hospital cares. I hear snippets of a conversation on the phone, the tub water running, a hair dryer blowing, a shower, and repeatedly telling the dog, Dante, to go back to bed when he wined because Jenny was in a different room.

read on

Nginx: do not cache logged in Drupal or WordPress users

A while ago I changed all of my domain names to Namecheap and migrated my Drupal and Wordpress sites to Linode. I followed some excellent instructions from James Sansbury (soon to be a Lullabot article) and some of his Nginx configuration files. This worked great for my Drupal site (heh - which was this site that I then converted to Jekkyl) and my wife’s WordPress site.

However, when my wife started using her blog on my fancy new Nginx setup with PHP-FPM, she noticed that when she created posts one after the other, they were overwriting eachother, effectively creating a new revision of the same post instead of creating a new one. I knew that this was because of the caching, but was still too new to Nginx to know exactly what to do about it.

Again, James to the rescue! He pointed me in the right direction and I got it working. Here’s what I did.

One of the relevant pieces of James’ setup, is this line within his /etc/nginx/nginx.conf:

http {
...
  ##
  # Virtual Host Configs
  ##

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
}

And then within /etc/nginx/conf.d/session_cookie.conf he searches for the cookie that Drupal sets when you log in:

# Determine if a Drupal session cookie is present
map $http_cookie $logged_in {
    default 0;
    ~SESS 1; # Drupal session cookie
}

To this, I added a search for the wordpress cookie as well:

# Determine if a Drupal session cookie is present
map $http_cookie $logged_in {
    default 0;
    ~SESS 1; # Drupal session cookie
    ~wordpress_logged_in 1; # Wordpress session cookie
}

The last piece is telling your site to bypass the cache if $http_cookie is set:

location / {
  ...
  # If client is logged in we bypass cache
  fastcgi_cache_bypass $logged_in;
  fastcgi_no_cache $logged_in;
  ...
}

A quick sudo service nginx restart and our WordPress site is working much better!

Angel of fire

``` Angel of fire, wings of light Visit me in my dreams tonight Tell me of love and burning desire Caress my lips, set me on fire

read on