Supercache and the permissions of Doom

I’ve been using a great plugin for Modx Revolution recently called Supercache which expands on the existing caching system and for complex sites can improve the performance of the website substantially.

So far so good, except the caching was so good it didn’t want to give up the cached files and trying to delete them through FTP held no joy either. So I had the choice of using a plugin that speeded up the site remarkably but not letting me update the pages, switching it off and having a slower site or tying to get the cache program to allow me to update.

After a great deal of internet searching, reading and experimentation I figured out that when the Modx CMS creates a file or folder it uses the default user of the apache process, that is the user called “apache” in a group of the same name. The problem arises when any of these CMS generated files needs to be deleted, the “clear cache” process uses the FTP user, not “apache” and as a result unless the files and folders are set at a permission level allowing the FTP user (not recommended) then those files are pretty much untouchable.

The solution is to simply make the FTP user and “apache” part of the same group and set the file permissions to 664 rather than the default 644, simple solution but one that needs to be better documented around the net!