1)全球可以在
AssetMananer的帮助下进行.有一个特殊的选项
$forceCopy.
您可以使用组件设置它:
use Yii; Yii::$app->assetManager->forceCopy = true;
或在应用程序配置中:
'components' => [ 'assetManager' => [ 'class' => 'yii\web\AssetManager','forceCopy' => true,],
2)如果要禁用特定AssetBundle中的缓存,请使用$publishOptions属性:
public $sourcePath = '...' // In order to use $publishOptions you should specify correct source path. public $publishOptions = [ 'forceCopy' => true,];
'components' => [ 'assetManager' => [ 'class' => 'yii\web\AssetManager','bundles' => [ 'yii\bootstrap\BootstrapAsset' => [ 'forceCopy' => true,
但是这个:
'forceCopy' => YII_DEBUG,
更灵活,因为它仅在调试模式下禁用此资产捆绑缓存,但允许在生产服务器上. YII_DEBUG设置在web / index.PHP中.