Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LanguageItemPluginAsset forceCopy causes overhead and timestamp change #119

Open
rhertogh opened this issue Apr 24, 2018 · 1 comment
Open

Comments

@rhertogh
Copy link
Contributor

Is it really necessary to force a copy in the LanguageItemPluginAsset?

This causes overhead in each request and prevents client side caching of the translation file (Yii appends the timestamp, but that changes on every request due to the forced copy)

image

@moltam
Copy link
Collaborator

moltam commented Apr 26, 2018

Well it depends.

I think the reason behind it is that this minimizes the possibility of serving an out of date language file. The language file is updated each time when a translation is modified. Without the forceCopy option, the Yii2 AssetManager will not update the file in the web folder (it will only publish once, when it detects that the file is missing), so the translations won't get updated. However if you use the linkAssets => true options in the AssetManager config, this will not be a problem (because of the symlink the file will always contain the latest translations). So you may need it in your specific environment, it depends on how you deal with assets.

Fortunately Yii2 provides a way to change the configuration for an asset bundle. If you don't need the forceCopy, you can turn of like this in the application config:

'assetManager' => [
    'bundles' => [
        \lajax\translatemanager\bundles\LanguageItemPluginAsset::class => [
            'publishOptions' => [
                'forceCopy' => false,
            ],
        ],
    ],
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants