Are the .js files being cached?

前端 未结 3 1565
梦如初夏
梦如初夏 2020-12-30 05:19

I recently made a website and I made a change to a .js file, but when I delete the .js file from the FTP server and upload the new one, the new file doesn\'t show up on the

3条回答
  •  再見小時候
    2020-12-30 06:12

    Yes. The resources are still cached. In my opinion a good practice to avoid this is to version your resources files in a url?parameter=value way.

    For example you should set the ulr to your js or css file like this: < ... src="script.js?v=1" .../> < ... href="style.css?v=1 .. /> and when any changes occured just change v=1 to v=2 ...

    that will not affect your code but will make your browser/proxy etc to redownload the resource

提交回复
热议问题