Beijing website constructionCompany Shangpin China: Search for the keyword. htaccess cache in the search engine. You can find many tutorials about setting up website file cache. By setting, you can cache files that are not updated frequently, such as css and js, on the browser side, so that visitors can visit yourWebsite productionThe browser can get css, js, etc. from the browser's cache without having to read from your server, which speeds up the opening of the website to a certain extent and saves your server traffic.
Now comes the problem. The css and js caches set by. htaccess have an expiration time. If the css and js have been cached in the visitor's browser, the browser will only read the css and js from the cache before these css and js caches expire. If you modify the css and js on the server, these changes will not change in the returning visitor's browser,Unless repeat customers press Ctrl+F5 to refresh your website page or manually clear the browser cache.There are thousands of visitors to a website, and there will be many repeat visitors. You can't let every visitor refresh the cache after updating the css. How will you deal with this problem?
Treatment
1. Add a version number to the css file: In fact, it is a bit troublesome to change the file name of the css file after each modification of the css file. Then we can add a version number (that is, the content behind the "" in the css link) to the load css statement.For example, the css call statement in the original html is as follows:
2. Change the css file name: In fact, it is very simple to solve this problem. The cache marks the cache content through the file name.After you update the content of the website's css file, you can change the name of the css file.For example, the css call statement in the original html is as follows:
In fact, the question mark behind the css file can only be used as a suffix. If you use the question mark plus parameter method, you can add version number and other information, and refresh the browser side cache.A small detail can bring us great convenience.