Peter Ruse
Peter Ruse

Reputation: 23

How to get Flask app to refresh after updating JS code without having to clear browsing data

I'm developing a Flask app using flask-socketio, running it with socketio.run(app, debug=True), but every time I update any of the app's Javascript code and then refresh the browser, the changes do not take effect. If I update any of the Python code and then refresh, the Python changes do take effect - the only problem is with Javascript changes.

Clearing my browser's data resolves the issue, but I don't want to have to do that every time I make changes to my JS code. Is there another way?

Upvotes: 1

Views: 470

Answers (2)

Kevin
Kevin

Reputation: 374

If clearing cache does work, then another method (which I always use) is to keep your developer tools opened and make sure you've checked "Disable cache" in the network tab.

The "Disable cache" feature only works when developer tools is opened as I said.

Upvotes: 0

Ben Gillett
Ben Gillett

Reputation: 386

Try ctrl-clicking (or shift-clicking) the refresh button.

What is likely happening is that the browser is "caching" your Javascript code. Clearing your browser's data clears the cache, and you get the newest updates...

In some browsers, you can avoid doing that by refreshing the page in a way that bypasses the cache. I think the shift-click trick works in Firefox, and ctrl-click is Chrome. Or, look up "bypass cache refresh [browser_name]".

Upvotes: 1

Related Questions