Clean up cache

Tags: Programming

In the process of web project development, we often refer to css and js files, and caching problems often occur after updating the files (clearly changed the code, access on the browser In this case, we usually use the following two solutions:

  1. Manually clear the browser cache
  2. Add the version number (such as layout.css ?v=1) Personally think that method 2 is faster, because clearing the browser cache has to wait for the browser to respond. But changing the version number every time is also very troublesome, so I need to find a way to automatically add the version number. The following is the method I collected: Method 1: You can automatically add the version number to html through js
1
2
3