JavaScript file not updating no matter what I do

前端 未结 13 765
粉色の甜心
粉色の甜心 2021-01-30 03:14

I have an external JavaScript file and whether in FireFox or Chrome, whether all browsing data is cleared, it will NOT update no matter what. I believe something happen

13条回答
  •  梦谈多话
    2021-01-30 03:46

    The best way around browsercaches is to append a random number to the path of the js file.

    Example in pseudo code:

    // generate a random number
    int i = Random.Next();
    echo "";
    

    This will make sure your browser always reloads the file, because it thinks it's a different file because of the random number in the url.

    The server will always return the file and ignore what comes after the '?'.

提交回复
热议问题