Search code examples
phpassetsyii2

Yii2 assets clear cache


Everytime I update my css or js files in infoweb\menu\module\assets, I have to empty the backend\web\assets folder
is there a way to automatically clear the assets cache?


Solution

  • Add this in your view:

    use vendor\myVendorName\myPackageName\assets\AppAsset;
    AppAsset::register($this);
    

    Add this in your config:

    'components' => [
        'assetManager' => [
            'linkAssets' => true,
        ], 
    ]  
    

    Empty assets folder, and refresh, done