src/Tasks/BuildAsset.php
protected function bustCacheBalls(string $asset_contents)
    {
        // Get some details about the asset
        $asset_ext = $this->destination->getExtension();
        $asset_name = $this->destination->getBasename('.'.$asset_ext);
        $asset_name_quoted = preg_quote($asset_name, '/');

        // Create our regular expression
        $search_for =
        '/'.
            $asset_name_quoted.'\..*?\.'.$asset_ext.'|'.
            $asset_name_quoted.'\..*?\.min\.'.$asset_ext.'|'.
            $asset_name_quoted.'\.min\.'.$asset_ext.'|'.
            $asset_name_quoted.'\.'.$asset_ext.
        '/';

        // This is the new asset name
        $replace_with = $asset_name.'.'.md5($asset_contents).'.'.$asset_ext;

        foreach ($this->template as $templateFile)
        {
            // Tell the world what we are doing
            $this->printTaskInfo('Updating template file - <info>'.$templateFile.'</info>');

            // Run the search and replace
            $this->collectionBuilder()
                ->taskReplaceInFile($templateFile)
                ->regex($search_for)
                ->to($replace_with)
            ->run();
        }

        // Grab the asset base dir
        $asset_base_dir = $this->destination->getPath();

        // Update the final asset filename to match
        $this->destination = new SplFileInfo($asset_base_dir.'/'.$replace_with);

        // Delete any old assets
        $files_to_delete = new Finder();
        $files_to_delete->files();
        $files_to_delete->name($asset_name.'.'.$asset_ext);
        $files_to_delete->name($asset_name.'.*.'.$asset_ext);
        $files_to_delete->name($asset_name.'.*.'.$asset_ext.'.gz');
        $files_to_delete->in($asset_base_dir);
        $files_to_delete->depth('== 0');
        foreach ($files_to_delete as $file_to_delete)
        {
            unlink($file_to_delete->getPathname());
        }
    }
protected function bustCacheBalls(string $asset_contents)
    {
        // Get some details about the asset
        $asset_ext = $this->destination->getExtension();
        $asset_name = $this->destination->getBasename('.'.$asset_ext);
        $asset_name_quoted = preg_quote($asset_name, '/');

        // Create our regular expression
        $search_for =
        '/'.
            $asset_name_quoted.'\..*?\.'.$asset_ext.'|'.
            $asset_name_quoted.'\..*?\.min\.'.$asset_ext.'|'.
            $asset_name_quoted.'\.min\.'.$asset_ext.'|'.
            $asset_name_quoted.'\.'.$asset_ext.
        '/';

        // This is the new asset name
        $replace_with = $asset_name.'.'.md5($asset_contents).'.'.$asset_ext;

        foreach ($this->template as $templateFile)
        {
            // Tell the world what we are doing
            $this->printTaskInfo('Updating template file - <info>'.$templateFile.'</info>');

            // Run the search and replace
            $this->collectionBuilder()
                ->taskReplaceInFile($templateFile)
                ->regex($search_for)
                ->to($replace_with)
            ->run();
        }

        // Grab the asset base dir
        $asset_base_dir = $this->destination->getPath();

        // Update the final asset filename to match
        $this->destination = new SplFileInfo($asset_base_dir.'/'.$replace_with);

        // Delete any old assets
        $files_to_delete = new Finder();
        $files_to_delete->files();
        $files_to_delete->name($asset_name.'.'.$asset_ext);
        $files_to_delete->name($asset_name.'.*.'.$asset_ext);
        $files_to_delete->name($asset_name.'.*.'.$asset_ext.'.gz');
        $files_to_delete->in($asset_base_dir);
        $files_to_delete->depth('== 0');
        foreach ($files_to_delete as $file_to_delete)
        {
            unlink($file_to_delete->getPathname());
        }
    }
So that we can bust the client cache in browser, we will rename the
asset filename, using a timestamp. But we also need to update the
HTML that includes the asset into the web page.
This method does all that for us.

@param string $asset_contents

@return void