Asset folder growth


I concerned about application assets folder grows!

I publish my widget assets with below code

$assetsUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.MapWidget.assets'),false,-1,false);

but when i add a new file for example css file to widget assets a new hash folder created in application assets though previous widget asset file doesn’t override or removed!

how can i fix this problem?

Its a simple thing to delete the contents of /assets/ … it will all just regenerate with the next request that needs whatever asset.

   // code from rights extension ;

           private $_assetsUrl ;

     public function getAssetsUrl()


                if( $this->_assetsUrl===null )


                        $assetsPath = Yii::getPathOfAlias('rights.assets');

                        // We need to republish the assets if debug mode is enabled.

                        if( YII_DEBUG )

                                $this->_assetsUrl = Yii::app()->getAssetManager()->publish($assetsPath, false, -1, true);


                                $this->_assetsUrl = Yii::app()->getAssetManager()->publish($assetsPath);


                return $this->_assetsUrl;


do you see the trick :

if in debug mode (means you often add or remove or update some js/image/css files ) , you should publish the dir every time . but if YII_DEBUG set to false . it will only publish once :lol:

tHr, you have extensions that help you in cleaning assets, like this one

yiqing95, In fact, even without forcing republishing of assets, they will be republished under a new hash if the original application/assets/ folder’s timestamp is modified. And that’s by design, and we need it like that indeed ;)