Web Connection
Live Reload doesn't always reload the files
Gravatar is a globally recognized avatar based on your email address. Live Reload doesn't always reload the files
  Tore Bleken
  All
  Dec 3, 2019 @ 04:31am

I use WWC 7.09 with Chrome. I notice that when I make changes in a .css or a .js file, the Live Reload doesn't always work. Pressing ctrl-F5 in Chrome fixes this, but it's a little bit annoying. You have spoiled us by adding this feature, I know...! 😃

The first umpty times this happened, I wondered why the heck my changes didn't update correctly, had I done something wrong? Having the focus on my own work, it didn't immediately occur to me that it might be a Chrome cache problem. Is this something we have to live with, or do you have any solution?

Gravatar is a globally recognized avatar based on your email address. re: Live Reload doesn't always reload the files
  Rick Strahl
  Tore Bleken
  Dec 3, 2019 @ 12:26pm

Unfortunately yes, it's something we have to live with. The WebSocket client code refreshes the page using the DOM refresh APIs with a full refresh flag, but browsers still choose to sometimes ignore the that especially for support dependencies like CSS files.

As you point out that's due to the caching in Chrome (or other browsers). I'm not really sure what triggers this - I think if you make a change that doesn't change the file size or a change that's made very closely after another change. The change won't refresh as the cache doesn't invalidate.

You can make this work if you leave the DevTools open. There's a Disable Cache option that basically forces all requests to refresh.

Gravatar is a globally recognized avatar based on your email address. re: Live Reload doesn't always reload the files
  Rick Strahl
  Tore Bleken
  Dec 14, 2019 @ 01:40am

I ended up making some changes in the WebSocket client code for Web Connection to keep it in sync with the code I'm using in my .NET Components and found that indeed the code wasn't using a forced refresh.

I've updated the module so that it does and it should work much better refreshing cached content now with the semi 'hard' refresh. You should now see CSS changes in most cases refresh as soon as you change and save. Note there is a small refresh timeout - so if you save within a few seconds in succession the file may not refresh - it will after 3 or 4 seconds however.

It's in the experimental file:

https://west-wind.com/files/WebConnectionExperimental.zip

There are a few other enhancements in the live reload module like retrying the connection if the server is shut down and restarted.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Live Reload doesn't always reload the files
  Tore Bleken
  Rick Strahl
  Dec 14, 2019 @ 01:55am

Thanks, seems to work fine.

© 1996-2024