Utsav Jain
Utsav Jain

Reputation: 11

Client-side javascript file not updating in some browser tabs on refreshing, but fine in new ones

I am making a full stack application using Django. I have some client-side Javascript written in a file called logic.js. I noticed that sometimes when I make changes in the logic.js file and then hit refresh in the browser, the browser's logic.js file doesn't change. However, if I open the site in another window, it gets the updated logic.js file. I am perplexed by this behavior of my browser (if it a browser problem). Why is this happening?

Upvotes: 1

Views: 1162

Answers (2)

Jameson Saunders
Jameson Saunders

Reputation: 95

For local development, make sure to disable the cache in you browser to make sure it always requests new data from the local server.

enter image description here

Upvotes: 1

BottleZero
BottleZero

Reputation: 983

Yeah, that will happen. I usually add a version in the template like:

<script src="{{ STATIC_URL }}app/js/filename.js?v={{ VERSION }}"></script>

where version is changed whenever I release an update. This should force the browser to grab the updated file.

Upvotes: 0

Related Questions