• Resolved taadike



    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 dcooney


    Hi @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.

    Great, thank you.

    This worked, thanks a lot.

    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;
    		   	// Hook dispatched after cache has been deleted
    		   	return __('Cache deleted successfully', 'ajax-load-more-cache');
    //      	}

    Any ideas how to make it work for average visitors?

    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.