Page 1 of 1
[Resolved] Google Chrome Javascript cache clearing? Oops, multiple javascript functions of the same name in the source
Posted: 07 February 2021, 14:58
by BrianLovesMarvel
Dear gurus,
I've been developing for several weeks and I can usually change my js and Ctrl-F5 to see my changes. But recently, Chrome has been stuck on a certain version of my javascript and I can't seem to clear the cache!
I've tried all the usual, Ctrl-F5 with/without the dev tools open, disabling caching in the dev tools network settings, long-press reload and clear cache and hard reload, browser settings clear cache all time. But afterwards I see this:
C:\Users\brian\AppData\Local\Google\Chrome\User Data\Default\Code Cache\js>findstr -M "studio.boardgamearena.com" *
0abc5544a0fe40e7_0
1d3b695aba756b2f_0
2a10defbc4281af6_0
9fc89be0f032ba95_0
b462e4b942615b96_0
bc36da75aa588ac3_0
f54c20f6b7220bf5_0
[edit: I was able to erase these by fully clearing cache, all time. The old javascript? Multiple functions of the same name passed to dojo.

]
How do I properly, reliably, and quickly clear javascript cache for Chrome?
Thanks, Brian
Re: Google Chrome Javascript cache clearing?
Posted: 07 February 2021, 15:26
by Archduke
This is what I do (ymmv):
1. Find the file which is not refreshing in the network/sources tab
2. Open it in a new tab
3. Do the usual big refresh (Ctrl-F5) on that new tab
4. Go back to the original page and refresh it
I usually use Safari for development though, and I don't have the problem there.
Re: Google Chrome Javascript cache clearing?
Posted: 07 February 2021, 15:48
by BrianLovesMarvel
Thanks - I've tried that too. The weird thing is, it first displays the old javascript in the dev tools, but if I right-click and open the js in new tab, it shows the new javascript!

I know BGA has the updated js. For example, dev tools shows in the console:
rescueatmtetna.js?1612708564810:1673
BGA links the javascript using a ?nnn I presume as a cache-buster (per
https://www.epochconverter.com/, 1612708564810 is the current time). But Chrome is still somehow holding onto and using an old version of my js?
Re: Google Chrome Javascript cache clearing? BGA cache?
Posted: 07 February 2021, 16:52
by BrianLovesMarvel
And this is even weirder... I completely reinstalled Chrome and get the same behavior. And installed Firefox and I get the same behavior.
I'm willing to be wrong here, but is BGA somehow delivering old javascript?
Re: Google Chrome Javascript cache clearing?
Posted: 07 February 2021, 17:15
by Victoria_La
Did you play around with "version" file in the project? That cannot change, it studio staging always version 999... (10)
Or did you copy project and some renaming did not work?
Other than that - BGA does not deliver stuff - you file sync does. When you sync you files to ftp folder it directly mapped
to staged server. I never hear of problem with JS cache. Only css and image cache is usually issue.
Re: Google Chrome Javascript cache clearing?
Posted: 07 February 2021, 17:26
by BrianLovesMarvel
No change of version or copying of code, I'm still on the same code and project.
My sftp connection is still working, as I can change the *tpl file for example and get changes to show.
My javascript file seems to save and load OK with sftp, but I can't get it sent to my browser. It shows the old one executing. If I directly access the javascript file, I can download the new version with the browser. But my old version is the one to execute.
I'm really puzzled!

Re: Google Chrome Javascript cache clearing?
Posted: 07 February 2021, 17:51
by BrianLovesMarvel
The javascript executing shows in the dev tools as
https://en.1.studio.boardgamearena.com: ... 2712889488
Code: Select all
notif_rollDice: function( notif ) {
console.log( 'Entering notif_rollDice' );
console.log( notif );
But if I right click and open in new tab I see
https://en.1.studio.boardgamearena.com: ... 2712664655
Code: Select all
notif_rollDice: function( notif ) {
console.log( 'Entering notif_rollDice' );
alert("Entering notif_rollDice");
console.log( notif );
I notice there is a "cache-busting" timestamp added to the URL js?nnn. But both of them are fairly recent. 1612712889488 = Today at 9:48am, 1612712664655 = Today at 9:44am. Both return the same updated javascript if I visit them manually.
I don't understand. Why I would get old javascript in the browsers when the game starts, if it is updated on BGA servers? Is there a CDN (content distribution network) involved?
Thanks, Brian
Re: Google Chrome Javascript cache clearing?
Posted: 07 February 2021, 18:21
by BrianLovesMarvel
I checked the network tab, and when the game starts, dojo.js triggers a load of the javascript.
The raw response to that request shows it is getting the new javascript from the BGA servers.
But when I run the game, and reference what is running via the console source link, it shows the old javascript.
I've completely reinstalled Chrome and wiped out all old data. This same thing happens on a new install of Firefox.
I'm sorely puzzled. Where is the old javascript coming from?

Re: Google Chrome Javascript cache clearing?
Posted: 08 February 2021, 02:29
by BrianLovesMarvel

OK, mystery solved.

As it often is, it was a problem between the chair and the keyboard.
Somehow when editing I had included multiple copies of javascript functions in the source file.
The later copies were overriding the newer ones.
Since these are just handed to dojo, they didn't trigger any javascript errrors.