Title: Delete post cache after trash
Last modified: September 1, 2016

---

# Delete post cache after trash

 *  [jmoria](https://wordpress.org/support/users/jmoria/)
 * (@jmoria)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/delete-post-cache-after-trash/)
 * When I “Trash” a post, the cache of that post is not deleted.
 * As I can see, this code should do the work, but it’s not working:
 * Line 677 in wpFastestCache.php
 *     ```
       }else if($new_status == "trash" && $old_status == "publish"){
       $this->deleteCache();
       ```
   
 * I tested on WampServer v2.5, with Windows 7.
 * [https://wordpress.org/plugins/wp-fastest-cache/](https://wordpress.org/plugins/wp-fastest-cache/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/delete-post-cache-after-trash/#post-7554537)
 * Did you check the cache files via ftp?
 *  Thread Starter [jmoria](https://wordpress.org/support/users/jmoria/)
 * (@jmoria)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/delete-post-cache-after-trash/#post-7554578)
 * Last time I made the test on my local WAMP server, installed on my PC. Now I 
   checked on my web server (1and1.com hosting), and found some very strange behavior.
 * When I “Trash” a post, the “all” directory is deleted (../wp-content/cache/**
   all**), not just the cache of the trashed post. It’s because you use **$this-
   >deleteCache()** (to delete whole cache) instead of **$this->singleDeleteCache(
   false, $post->ID)** (to delete only single post cache).
 * BUT, I changed **$this->deleteCache()** to **$this->singleDeleteCache(false, 
   $post->ID)** and again it’s not working. It’s very strange because a few lines
   below (on post update) it’s working fine, the cache of updated post is deleted,
   but when I use **$this->singleDeleteCache(false, $post->ID)** for trashed post–
   it’s not working.
 * Everything is tested via FileZilla.
 *  Thread Starter [jmoria](https://wordpress.org/support/users/jmoria/)
 * (@jmoria)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/delete-post-cache-after-trash/#post-7554583)
 * Also, I replaced **$this->deleteCache()** (line 678) with the code below, and
   it’s working fine, haha.
 *     ```
       $permalink = get_permalink($post_id);
   
       if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $permalink, $out)){
       	$path = $this->getWpContentDir()."/cache/all/".$out[1];
       	$mobile_path = $this->getWpContentDir()."/cache/wpfc-mobile-cache/".$out[1];
   
       	if(is_dir($path)){
       		$this->rm_folder_recursively($path);
       	}
       	if(is_dir($mobile_path)){
       		$this->rm_folder_recursively($mobile_path);
       	}
       }
       ```
   
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/delete-post-cache-after-trash/#post-7554640)
 * ok 🙂
 *  Thread Starter [jmoria](https://wordpress.org/support/users/jmoria/)
 * (@jmoria)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/delete-post-cache-after-trash/#post-7554645)
 * So, what do you think? Will you update the plugin to delete only the cache of
   the trashed post, not the whole cache? It would be great if you do that, it’s
   much better than deleting whole cache when only one post is trashed.
 * Also, do you have any clue why $this->singleDeleteCache(false, $post->ID) is 
   not working for trashed post?
 * Sorry for bothering you, I just want to make this plugin even better.
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/delete-post-cache-after-trash/#post-7554646)
 * Only you wanted this feature. and this is not so important feature so I cannot
   promise 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Delete post cache after trash’ is closed to new replies.

 * ![](https://ps.w.org/wp-fastest-cache/assets/icon-256x256.png?rev=2064586)
 * [WP Fastest Cache - WordPress Cache Plugin](https://wordpress.org/plugins/wp-fastest-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-fastest-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-fastest-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-fastest-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-fastest-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-fastest-cache/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/delete-post-cache-after-trash/#post-7554646)
 * Status: not resolved