How can I force clients to refresh JavaScript files?

后端 未结 26 2201
旧时难觅i
旧时难觅i 2020-11-22 03:40

We are currently working in a private beta and so are still in the process of making fairly rapid changes, although obviously as usage is starting to ramp up, we will be slo

26条回答
  •  你的背包
    2020-11-22 04:10

    You can add file version to your file name so it will be like:

    https://www.example.com/script_fv25.js
    

    fv25 => file version nr. 25

    And in your .htaccess put this block which will delete the version part from link:

    RewriteEngine On
    RewriteRule (.*)_fv\d+\.(js|css|txt|jpe?g|png|svg|ico|gif) $1.$2 [L]
    

    so the final link will be:

    https://www.example.com/script.js
    

提交回复
热议问题