yii\web\AssetManager
(定義資源文件包),`yii\web\AssetBundle
(資源包之間的文件依賴,加載和建立).有如下幾個解決思路://配置 main.php components數組下assetManager 'assetManager'=>[ //緩存相同的文件到相同的一個文件夾 'hashCallback'=>function($path){ return hash('md4', $path); }, //添加文件時間戳 'appendTimestamp' => true, ],
同步緩存目錄,這個相對來講是很簡單.就是保持2個服務器的有相同的一份靜態資源,手動同步就是 FTP 上傳,自動同步就是2個服務器之間相互請求保持一致便可.有工具能夠使用:Linux rsync目錄同步php
'assetManager'=>[ 'bundles'=>[ //jquery.js 'yii\web\JqueryAsset' => [ 'sourcePath' => null, 'baseUrl' => 'https://cdn.bootcss.com/jquery/2.2.4/', ], //Yii.js 'yii\web\YiiAsset' => [ 'sourcePath' => null, 'baseUrl' => 'http://p8mo8fh1z.bkt.clouddn.com/', ], //bootstrap.css 'yii\bootstrap\BootstrapAsset' => [ 'sourcePath' => null, 'baseUrl' => 'https://cdn.bootcss.com/bootstrap/3.3.7/', ], //bootstrap.js 'yii\bootstrap\BootstrapPluginAsset' => [ 'sourcePath' => null, 'baseUrl' => 'https://cdn.bootcss.com/bootstrap/3.3.7/', ], ] ],