Skip to content

Offload "Purge Entire Cache" request to cron service/schedule #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions admin/class-fastcgi-purger.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,31 @@ public function custom_purge_urls() {
}

/**
* Purge everything.
* Schedule Purge everything.
*/
public function purge_all() {
public function purge_all()
{

// Schedule the action if it's not already scheduled
// This to avoid overhead of buffering when there are too many directories
if (!wp_next_scheduled("nginx_helper_unlink_recursive")) {
wp_schedule_single_event(
time(),
"nginx_helper_unlink_recursive",
[RT_WP_NGINX_HELPER_CACHE_PATH, false]
);
}

$this->unlink_recursive( RT_WP_NGINX_HELPER_CACHE_PATH, false );
$this->log( '* * * * *' );
$this->log( '* Purged Everything!' );
$this->log( '* * * * *' );
$this->log('* * * * *');
$this->log('* Purged Everything has been scheduled');
$this->log('* * * * *');

/**
* Fire an action after the FastCGI cache has been purged.
*
* @since 2.1.0
*/
do_action( 'rt_nginx_helper_after_fastcgi_purge_all' );
do_action('rt_nginx_helper_after_fastcgi_purge_all');
}

/**
Expand Down
Loading