By a total accident I have figured out that my frontend and backend folder are huge (65M+). Quick inspection had proven that my app is using a set of only three assets, but for some reason Yii has generated (published) each of them three times:
As you can see, in some cases the same huge Bootstrap 5 asset has been published twice in the same date, hour and minute. So between 2-3 refreshes of the page. And between less than 60 seconds my assets folder has got extra 19 MB.
So, my question is:
When or under exactly which conditions Yii 2 may decide to publish exactly the same asset (as it already have published) under new asset ID?
Is there anything I can do to prevent this?
Can I do something (and what) to make my both apps (backend and frontend) reusing the same assets folder (i.e. /common/web/assets?) instead of separate one for each of these apps? Is it worth extra code of it? Or maybe an answer to the next question is the problem’s solution?
Can I delete extra assets at all? And, if yes, which one (all of them?) and when (some hours or days after publication)?
The last one seems most important. If I can consider some automated script that runs i.e. on daily basis and simply purges all or some folders out of assets folder?
No change in source files (i.e. the same out-of-the-box Bootstrap 5 deployment)
No change in version of any package (composer not touched at all)
No change in destination folder (nothing deleted, removed or renamed)
PHP guide says: “filemtime – Gets file modification time”. But what has been modified?
With the above assumptions, my assets folder should stick unmodified until the cold death of the universe, because nothing ever gets modified. And yet, I am getting Bootstrap 5 deployed after Bootstrap 5, sometimes twice per minute ← that’s the key of the problem and the key of this question.
Where should I start tracing on what changes what, to trigger the whole process? As per my knowledge nothing changes on either side.
For me this looks either as a bug or very, very complicated and confusing algorithm.
Again, I am trying to trace the roots of the problem to try to understand it. You have already provided me with the solution – some CRON task that will purge assets folder on regular basis.
But, I really would like to know, what exactly I am doing that I am causing Bootstrap 5 to be published to assets folder twice per minute and then there’s a “silence” of six days.