Title: Delete cache
Last modified: June 22, 2018

---

# Delete cache

 *  Resolved [taadike](https://wordpress.org/support/users/taadike/)
 * (@taadike)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/delete-cache-3/)
 * Hello,
 * Is there a way to delete cache whenever a visitor clicks a button?
    We have upvote/
   downvote buttons below each post so in order to display the correct post rating
   we need to clear cache each time either of the buttons is clicked.

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

 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/delete-cache-3/#post-10425600)
 * Hi [@taadike](https://wordpress.org/support/users/taadike/),
    I just checked 
   the docs and it appears there is not a public method for easily clearing the 
   ALM cache.
 * In the add-on there is a `alm_delete_full_cache` method that may useful.
 * You would have to call it via php or Ajax if the action is triggered with javaScript.
 * You would trigger `ALMCache::alm_delete_full_cache()`
 * Let me know if this helps.
 *  Thread Starter [taadike](https://wordpress.org/support/users/taadike/)
 * (@taadike)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/delete-cache-3/#post-10425648)
 * Great, thank you.
 *  Thread Starter [taadike](https://wordpress.org/support/users/taadike/)
 * (@taadike)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/delete-cache-3/#post-10425842)
 * This worked, thanks a lot.
 *  Thread Starter [taadike](https://wordpress.org/support/users/taadike/)
 * (@taadike)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/delete-cache-3/#post-10426041)
 * Seems like this works only for admins. If a visitor clicks the button then cache
   is not deleted.
    I also found this function and even though I removed this line
   it still didn’t work for average visitors: // if (current_user_can( apply_filters(‘
   alm_custom_user_role’,
 *     ```
             public static function alm_delete_full_cache(){
   
       //      	if (current_user_can( apply_filters('alm_custom_user_role', 'edit_theme_options') )){
   
             		$path = ALMCache::alm_get_cache_path();
       		   	foreach (new DirectoryIterator($path) as $directory) {
       		         if ($directory->isDot())  continue;
   
       		         if ($directory->isDir()){
       		            $path_to_directory = $path . $directory;
       		            self::alm_cache_rmdir($path_to_directory);
       		         }
       		   	}
   
       		   	// Hook dispatched after cache has been deleted
       		   	do_action('alm_cache_deleted');
       		   	return __('Cache deleted successfully', 'ajax-load-more-cache');
   
       //      	}
   
             	wp_die();
   
             }
       ```
   
 * Any ideas how to make it work for average visitors?
 *  Thread Starter [taadike](https://wordpress.org/support/users/taadike/)
 * (@taadike)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/delete-cache-3/#post-10442122)
 * Hey, never mind about this, I have resolved this now 🙂

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

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

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [taadike](https://wordpress.org/support/users/taadike/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/delete-cache-3/#post-10442122)
 * Status: resolved