When developing web pages, CSS is often used to design web page styles. At this time, the specified css style file is usually embedded into the corresponding page through the link method. When using writing styles, it is often tested and observed through web pages. Because when testing the effects of different design styles, the content of the css style file will be frequently modified, and the page will be refreshed before the .css file is modified once to see the new effect. However, at this time, we often encounter an annoying thing, that is, after modifying the style file, we cannot see the effect of the new style by refreshing the web page. The reason is that browsers such as IE automatically cache files when browsing web pages. When refreshing the web page, the browser does not restart to obtain new CSS style content from the server, resulting in the new styles not being applied to the web page in time. . This will bring inconvenience to our development process. In response to this situation, according to Xiaoyu's reminder, there are currently the following solutions:
Method 1: Dynamically modify the href attribute of the link tag so that the href attribute value obtained each time you visit the webpage is different from the last time ( For example, you can add parameters to the css text url, such as "*.css?param", and dynamically change the value of the parameter param to change the href attribute value). In this way, every time the browser accesses it, the corresponding href The value is different from the old version and the new version of the css file is automatically accessed and obtained. Therefore, the newly modified css style can be applied to the page in time.
Method 2: Set the browser to automatically check the latest version of the saved web page, so that the browser will automatically check and obtain the latest version of the css file every time. [Steps (take IE as an example): Tools-Internet Options-Temporary Internet File Settings-Check the latest version of the saved web page automatically. 】
In this way, you can get the latest web page version in time every time!