0

My Yii2 assets bundles timestamp always keep updating on each page reload.

// Configuration:

'assetManager' => [
        'appendTimestamp' => true,
        'linkAssets' => getenv('LINK_ASSETS'),
        'class' => 'yii\web\AssetManager',
        'bundles' => [
            'yii\web\JqueryAsset' => [
                'js'=>[]
            ],
            'yii\bootstrap\BootstrapAsset' => [
                'css' => []
            ],
            'yii\bootstrap\BootstrapPluginAsset' => [
                'js' => []
            ]
        ],
    ],

<script src="/assets/e61789e4/yii.js?v=1500890158"></script>
<script src="/assets/e0852aa8/jquery.inputmask.bundle.js?v=1500890158"></script>
On page reload:
<script src="/assets/e61789e4/yii.js?v=1500890675"></script>
<script src="/assets/e0852aa8/jquery.inputmask.bundle.js?v=1500890676"></script>

How can I get keep them static? Sorry for my english.

arman
  • 1
  • 2
  • Seems that your files overwritten each time. I think you should debug this part https://github.com/yiisoft/yii2/blob/master/framework/web/AssetManager.php#L524 – SiZE Jul 24 '17 at 10:21
  • or according to your prop `'linkAssets' => getenv('LINK_ASSETS')` this https://github.com/yiisoft/yii2/blob/master/framework/web/AssetManager.php#L519 Try to comment this setting. – SiZE Jul 24 '17 at 10:22

1 Answers1

0

Set 'appendTimestamp' to false, it will not add timestamp at the end of linked file:

'assetManager' => [
        'appendTimestamp' => false,    // here's the magic
        'linkAssets' => getenv('LINK_ASSETS'),
        'class' => 'yii\web\AssetManager',
Yupik
  • 4,932
  • 1
  • 12
  • 26
  • I think the author wants to know how to prevent assets to be updated. – SiZE Jul 24 '17 at 10:19
  • @SiZE where he said something about that? He want to keep bundles static on page reload, because for now timestamp is changing every page reload. – Yupik Jul 24 '17 at 10:44
  • timestamp changes only if assets was modified. It shouldn't be updated on each request. – SiZE Jul 24 '17 at 10:55