DarkHorrorOfThirdEye
DarkHorrorOfThirdEye

Reputation: 45

Html online reload without pressing ctrl+f5

I'm struggling with this for a while now, whenever I upload a script to my website, it doesn't show up until I press Ctrl + F5 or any other alternative, I know it works but if this website of mine gets a publicity, its not like I can tell all the people to go on a computer and press Ctrl+F5 or something, its dumb, I want it to be like all the other websites, I press refresh, (not ctrl+f5) and all the new updates are loaded! if there is some sort of HTML, CSS, code that could help will be well appreciated! Thanks in advance.

Upvotes: 1

Views: 943

Answers (1)

Reza Saadati
Reza Saadati

Reputation: 5429

Instead of

<script src="script.js">

you could use

<script src="script.js?version=1">

By increasing the number 1 each time you upload a new script, you are bypassing the cache.

Instead of 1, you could also create a random number in backend. For instance in PHP:

<script src="script.js?version=<?= time(); ?>">

Upvotes: 1

Related Questions