University Marketing & Communications

August 8, 2011

Supercache on a Read-only filesystem

By Chris Heiland

This was originally posted on Chris Heiland’s staff blog while he was a member of the Web Team. Chris migrated this post to the Web Team blog before he left because we thought the content still had value to the UW community.


I’ve finally gotten around to solving an interesting problem. For security purposes our primary webserver is read-only which makes some normally trivial tasks extremely difficult. Originally the system was design to push static files to the front end cluster so the web server could deliver.

However, as technology has progressed we have moved from static files to dynamic systems. When the underlying infrastructure doesn’t change, setting up a new system can be┬áchallenging. In this case we have a requirement for a plugin that needs the ability to write to disk.

The good news is there is temp space on the production servers we can get access to. The other good news is the push process allows us to create and push symlinks. So the first step is to know what directories are needed, if we look at a working copy of supercache we know that there are two files and one directory.

wp-content/cache
wp-content/wp-cache-config.php
wp-content/advanced-cache.php

In the supercache documentation we see the manual setup process includes making a change to the advanced-cache.php file. Basically there is a constant that needs the full path to the wp-super-cache plugin directory.

The other change is to setup the wp-cache-config.php file with your custom settings. This can be done on the front end end, however, since this needs to be completed on a per-host basis it is easier to set it up once and then push everything.

The last is to setup the cache directory and point it to the right place. Supercache will populate it so all you need to do is give it an empty directory to use. Now that we have everything in place we can enable supercache and it all should work.

Naturally I have a script to do all this, but since it reveals UW specific information please contact me directly.

Cheatsheet

  • Setup tmp space on production server
  • symlink files and directory to space on server
  • push all files in the content directory

References