R
R
Ruslan2017-05-31 18:00:22
Yii
Ruslan, 2017-05-31 18:00:22

yii2 framework doesn't see changes made to js and css files?

Hello. I develop on a local PC using OpenServer and yii2.
When I start the server and start making changes to js or css files, these changes are not visible in the browser, the server sends the version of the files that was before the change.
When I change the file name and links in AppAsset, the changes after that begin to see.
I have it in my web config

'assetManager' => [
            'class' => 'yii\web\AssetManager',
            'linkAssets' => true,
            'forceCopy' => true,//YII_ENV_DEV ? true : false
        ],

and in the folder / web / assept deleted all the files, but this does not help, because after each reload of the site it creates shortcuts.
I also tried to write the following in AppAssept:
public $publishOptions = [
        'forceCopy' => true
    ];

The result is the same.
How to fix it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Khomenko, 2017-05-31
@Rysl_prog_diz

1. Run OpenServer with administrator rightsso that it can create symlinks.
2. In the configuration, set up the asset manager:

'assetManager' => [
    'linkAssets' => true,
    'appendTimestamp' => true,
],

...and enjoy.
It makes no sense to include both linkAssets and forceCopy at the same time. The first parameter publishes assets via symlinks, the second makes a complete copy of the asset files. I prefer the option you mentioned above. It works great for me.
P.S. Carefully read the documentation, almost all of this is written there, and even in Russian.

M
Maxim Timofeev, 2017-05-31
@webinar

I start making changes to js or css files, these changes are not visible in the browser, the server sends the version of the files that was before the change.

Are you sure it's not the browser's cache? ctrl+f5 doesn't solve the problem?
And another nuance, if the files are in assets, then you need to manually clean the assets folder

N
Nik Gubin, 2017-05-31
@gubin_niko

Ctrl+F5 works?
Certainly not caching? I have this on OpenServer all the time when I work on Windows.
Open the desired file and refresh it (in the browser), the changes will then be loaded.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question