Forums

Auto flush nginx cache (1 post)

  1. Takayuki Miyauchi
    Member
    Posted 7 months ago #

    Hey there!

    I am developer of nginx-champuru.
    http://wordpress.org/extend/plugins/nginx-champuru/

    I want to implement auto flush nginx cache on this plugin.

    public function flush_caches()
    {
        if (defined("NGINX_DELETE_CACHES") && NGINX_DELETE_CACHES) {
            if (defined("NGINX_CACHE_DIR") && NGINX_CACHE_DIR) {
                $this->cache_dir = NGINX_CACHE_DIR;
            }
            $cmd = sprintf(
                'grep -lr %s %s | xargs rm -f >/dev/null &',
                escapeshellarg(home_url()),
                escapeshellarg($this->cache_dir)
    
            );
            exec($cmd);
        }
    }

    This function will exec on the hooks below.
    (publish_future_post hook will work by ajax.)

    • save_post
    • publish_future_post
    • comment_post

    I want to implement this function safely.
    Please advice me!

    If there are some mistakes in English, I'd like to apologize.

Reply

You must log in to post.

About this Topic

Tags