Title: [Plugin: WP Super Cache] Cannot delete cache folder after uninstall
Last modified: August 19, 2016

---

# [Plugin: WP Super Cache] Cannot delete cache folder after uninstall

 *  [Dr C](https://wordpress.org/support/users/dr-c/)
 * (@dr-c)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/)
 * I installed WP-Super-Cache but couldn’t get it to work. I had the same problem
   with the Mod Rewrite as [here](http://wordpress.org/support/topic/178080?replies=1).
   Anyway, I figure WP-Cache will be enough for my needs. So I set about uninstalling.
   All went fine but I cannot remove the cache folder. I chmod it to 777 but permission
   is denied – the owner/group is httpd and this might be the problem. I had the
   same problem with the advanced-cache.php (folder-looking file) but moving it 
   into another folder and then deleting that folder (of which I was the owner/group)
   worked. This approach does not work with the cache folder since I do not have
   permission to move it. I even backed up my wp-content folder, without the rogue
   cache folder, and tried to delete the wp-content folder on the server. Of course
   everything else deleted except the cache folder!
 * Any help on how I can remove this dang folder is much appreciated!

Viewing 9 replies - 16 through 24 (of 24 total)

[←](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/?output_format=md)
[1](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/?output_format=md)
2

 *  [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772420)
 * Put opening and closing PHP tags at the top and bottom of that file. <?php and?
   >
 *  789700
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772430)
 * put the code at which file and also location?
    I am cracking my head and i cant
   find the way to do it i would like to do a fresh installation…. Please help!!!
 *  [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772431)
 * Put it into wp-content/t.php and then call [http://yourhostname.tld/wp-content/t.php](http://yourhostname.tld/wp-content/t.php)
 * If you see an error, you may need to add this line at above the rmdir() commands:
 * unlink( cache/.htaccess );
 *  [arminbw](https://wordpress.org/support/users/arminbw/)
 * (@arminbw)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772436)
 * It’s not as simple as that. The supercache directory is full of subdirectories.
   In my case I had to use a recursive function:
 *     ```
       <?php
       function removeDir($dirname)
       {
           if (!file_exists($dirname)) {
               return false;
           }
           if (is_file($dirname)) {
        	echo ("deleting: " . $dirname . '<br />');
               return unlink($dirname);
           }
           $dir = dir($dirname);
           while (false !== $entry = $dir->read()) {
               if ($entry == '.' || $entry == '..') {
                   continue;
               }
               echo ("deleting: " . $dirname . DIRECTORY_SEPARATOR . $entry . '<br />');
               removeDir($dirname . DIRECTORY_SEPARATOR . $entry);
           }
           $dir->close();
           return rmdir($dirname);
       }
   
       unlink("cache/.htaccess");
       removeDir("cache/meta");
       removeDir("cache/supercache");
       removeDir("cache");
       ?>
       ```
   
 * Use at your own risk.
 *  [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772437)
 * arminbw – did you have to use that with the latest version of the plugin? The
   deactivate hook calls a function that clears the cache directory and does what
   your function above does.
 *  [arminbw](https://wordpress.org/support/users/arminbw/)
 * (@arminbw)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772438)
 * Yes, I used the latest version. But generally the plugin didn’t work for me very
   well. Edited posts didn’t get updated and the [supercache folder only contained empty subdirectories](http://wordpress.org/support/topic/199638).
 * I will try to install the plugin on another server, where I have root access,
   so I can investigate this a bit..
 *  [senky](https://wordpress.org/support/users/senky/)
 * (@senky)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772455)
 * **arminbw’s** PHP code is realy function, I used it and it deleted all this directories
   and files.
 * (arminbw – Thanks 🙂 )
 *  [csschris](https://wordpress.org/support/users/csschris/)
 * (@csschris)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772456)
 * I was able to delete advanced-cache.php by creating a new directory, moving the
   advanced-cache.php into it and deleting it.
 *  [psionmark](https://wordpress.org/support/users/psionmark/)
 * (@psionmark)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772463)
 * I had a similar problem removing the files. Moving the entire directory to another
   directory allowed me to then delete it.
 * Mark

Viewing 9 replies - 16 through 24 (of 24 total)

[←](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/?output_format=md)
[1](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/?output_format=md)
2

The topic ‘[Plugin: WP Super Cache] Cannot delete cache folder after uninstall’ 
is closed to new replies.

 * 24 replies
 * 12 participants
 * Last reply from: [psionmark](https://wordpress.org/support/users/psionmark/)
 * Last activity: [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cannot-delete-cache-folder-after-uninstall/page/2/#post-772463)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
