A cache directory is a temporary directory

WOAH! Do not put symlinks to your uploaded files in a temporary cache directory. Nginx users running WordPress should beware if they followed these instructions and put a symlink to uploaded files in the wp-content/cache/ directory. I’m going to rewrite that page right now suggesting they use a different directory, possibly wp-content/uploads/ or maybe wp-content/files/.

WP Super Cache (and I presume other caching plugins) will delete everything in the cache directory. It’s like putting important files in /tmp/ where files are routinely cleaned out on reboot.

My replies on the thread above might paint me as a cold heartless bastard but I am sorry those websites suffered data loss. However I’m shocked that they put links to uploaded images in a folder containing temporary files!

Edit (20 minutes later): the codex page has been updated, thanks Westi for your help. It now recommends using wp-content/ms-filemap/ rather than wp-content/cache/

5 thoughts on “A cache directory is a temporary directory

    1. I don’t think it is. If you have permission to create a symlink in the cache directory and can do so without the website owner’s permission then you can upload a script that deletes all their uploaded files quite easily.

  1. I wanted to load your wp super cache. I was told that for beginners, (and i am a novice, so i need something that works, and i do not need to worry about it), super cache is the best. However, it says on wp that it has not been tested in 3.3. When i read people lose things, it scares me. Are you going to test this to work in 3.3. thanks.

    1. It works fine in 3.3, and this data loss was not because of a bug in the plugin. It was because of an unfortunate choice of location for a link to upload files. It never made sense to put that link there in the first place..

      At least 16,000 sites use the plugin so that’s a pretty good indication of how reliable it is.

  2. Donncha, I agree it’s silly to place ms-filemap inside the cache dir.
    On the other hand, “rm -rf” doesn’t follow symlinks. I guess people would expect a cache prune to work in the same way.

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.