2

I am totally lost, don't even know what to google anymore, maybe someone can push me in the right direction here:

I have a WildFly Server running, and I did some changes to a JavaScript file. As soon as I republished the new .war file to the server, the changes caused by the new js file were visible in my browser on the computer.

Yet, as I opened my phone to check the results there, nothing happened. I cleared the cache and, of course, now the changes appeared. On both, computer and phone, I was using Chrome.

I put the HTTP Header "Cache-Control" with "no-cache" as value, but that didn't do anything. I use NGINX in front of the WildFly, but I checked and NGINX does not filter out that header.

I also tried versioning the files. WildFly offers a very neat solution for that, if you stumble across this question, check out this post to see how that is done. But this didn't do the trick for me either.

Does anybody know what might be going on here?

Thanks for any help or comments!

Maverick283
  • 1,284
  • 3
  • 16
  • 33

3 Answers3

3

It ended up being a timing issue. The browsers on the phones eventually reloaded the current files, and since then changes are visible immediately.

The script trick with the version number works like a charm. So do the headers ("Cache-Control: no-cache"). Both together are probably pretty fail safe. One can't do it all with version numbers, only the includes.

Thanks @Azametzin for the input!

Maverick283
  • 1,284
  • 3
  • 16
  • 33
1

If the cache cleaning through "Cache-Control" is failing somehow, another solution would be to set a new version for JavaScript file. For example:

<script type="text/javascript" src="script.js?v=0.01"> // any version number you want

I'm not very used to WildFly Server, but I believe you could set a function for creating a random number that will be used as the new version everytime the page is refreshed.

Something like: <script type="text/javascript" src="script.js?v={random number here}">

Hope it gives you a direction to follow.

Azametzin
  • 5,223
  • 12
  • 28
  • 46
  • Hey, thanks for your help. I forgot to mention that I already did that though. There is indeed a very good easy way to do that in Wildfly, I'll post that in the question soon. But, it didn't help. I was told it's the same on Safari, yet only on mobile devices. Could it be some sort of data saving stuff? – Maverick283 Aug 16 '19 at 05:59
  • Yes, it can be it. I don't know about Wildfly, but I know it happens through other platforms. – Azametzin Aug 16 '19 at 11:41
0

Not all browser which cache-control supports in some browsers in Android device (Not Chrome Android), because the cache-control still works in android device. Some browser which taken from Android doesn't work.