Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 assets clear cache

Tags:

php

assets

yii2

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?

like image 567
Ruben Avatar asked Jul 18 '14 07:07

Ruben


People also ask

How to clear cache in Yii2?

When you need to invalidate all the stored cache data, you can call yii\caching\Cache::flush(). You can flush the cache from the console by calling yii cache/flush as well.

How to use cache in Yii2?

Simple Data Caching So we start by setting a value to be cached. To do so, we will also have to assign it a unique ID. For example: // Storing $value in Cache $value = "This is a variable that I am storing"; $id = "myValue"; $time = 30; // in seconds Yii::app()->cache->set($id, $value, $time);


1 Answers

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

like image 160
Ruben Avatar answered Sep 29 '22 20:09

Ruben