How to force the browser to reload cached CSS/JS files?

后端 未结 30 4405
青春惊慌失措
青春惊慌失措 2020-11-21 05:49

I have noticed that some browsers (in particular, Firefox and Opera) are very zealous in using cached copies of .css and .js files, even be

30条回答
  •  自闭症患者
    2020-11-21 06:01

    For development: use a browser setting: eg. Chrome network tab has a disable cache option.

    For production: append a unique query parameter to the request (eg. q?Date.now()) with a server-side rendering framework or pure javascript.

    //pure javascript unique query parameter generation
        //=== myfile.js
        function hello() { console.log('hello') };
        //=== end of file
    
    
    
          ')
            
    

提交回复
热议问题