How to clear the browser cache ?, Clear browser cache?
Some strange problems are often encountered in web development. For example, if a problem is found, the script is changed, and the problem persists after the result is published, but on the server, the released script has indeed been changed !! The last thing I found was that the browser cache was playing a strange role !!
Several Methods to clear browser cache are discussed.
One principle is that the HTTP Header parameter Cache-Control is used to clear the Cache, and the other is to use the URL to add query strings to fool the browser to forcibly read data from the server to avoid caching.
1. Clear data using HTTP
Cache-ControlParameters include:
- max-age=[Unit: Second seconds]-sets the maximum cache validity period. SimilarExpiresHowever, this parameter defines the time (for example, 60) rather than the specified time point. The unit is [second seconds].
- s-maxage=[Unit: Second seconds]-similarmax-ageBut it is only used for public cache (e.g., proxy ).
- public-The response is cached and shared among multiple users. Normally, if HTTP authentication is required, the response is automatically set to private.
- private-The response can only be used as a private cache (e.g., in a browser) and cannot be shared between users.
- no-cache-The response is not cached, but requests resources from the server in real time. This is useful to ensure that HTTP authentication can strictly prohibit caching to ensure security (this is when the page is used together with the public ). it neither sacrifices the cache efficiency nor ensures security.
- no-store-Under any conditions, the response will not be cached and will not be written to the client disk. This is also used for some sensitive responses based on security considerations.
- must-revalidate-The response will be reused under certain conditions to meet the subsequent request, but it must go to the server side to verify whether it is still up-to-date.
- proxy-revalidate-Similarmust-revalidateBut not applicable to proxy cache.
Specific use:
Add
<meta http-equiv="pragma" content="no-cache" /> <meta http-equiv="content-type" content="no-cache, must-revalidate" /> <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT"/>
Asp.net output can be used
Response.Buffer = True ;Response.ExpiresAbsolute = Now() - 1 ;Response.Expires = 0 ;Response.CacheControl = "no-cache" ;Response.AddHeader "Pragma", "No-Cache" ;
2. Add query strings
Generally, there are two ways to add a random number. An error occurred while adding the random number.
For example, add a random number
document.write("<script src='test.js?rnd="+Math.random()+"'></s"+"cript>")
Add Timestamp
url: "../SurveyGetRecordData.aspx?date="+(new Date().getMilliseconds())
We can see that these two methods force the client to read data from the server every time and do not use the cache at all. But what if the js style is rarely changed? Use the cache. If the script is modified, the client always uses the script that has not been changed, which is equal to no modification !! No cache is used, and the script is rarely changed. It is read from the server every time and is not necessary !! How can this problem be solved ??
In fact, it is very simple to use the query string and add a query string similar to the version number. If it is modified, change this parameter. Otherwise, it will not be changed, you can cache the data as needed.
For example:
<script type="text/javascript" src="../jquery-easyui/jquery-1.8.0.min.js?ver=1711"></script>
How to clear the IE cache?
☆Ie6
1. Click the tool menu.
2. Select Internet.
3. Click the regular tab.
4. Click Delete file.
5. Click OK in the confirmation window.
6. Click OK to close the "Internet Options" window.
☆Ie 7
1. Click the tool menu. If you cannot find the menu, press the Alt key on the keyboard to display the menu.
2. Select Delete Browsing History.
3. Click Delete file.
4. Click the Yes button in the confirmation window.
5. Click Close.
☆I E8
1. Click the tool menu. If you cannot find the menu, press the Alt key on the keyboard to display the menu.
2. Select Delete Browsing History.
3. Select the Internet temporary files check box.
4. Click Delete.
5. delete the file and click OK.
☆Firefox
To clear the Mozilla Firefox cache, follow these steps:
1. Click the "Tools" menu at the top of the browser and select "Options ).
2. Click "Privacy ).
3. Click "Clear" next to "Cache ).
4. Click OK ).
☆Maxthon)
1. Click the "Tools" menu at the top of the browser and select "Internet Options ".
2. In general, select Delete Browsing History.
3. Select an Internet temporary file
4. delete the file and click Close.
☆Google chrome
To clear the chrome cache, follow these steps:
1. Click the small wrench icon.
2. Select "option"
3. Select "Personal Data"
4. In data browsing, click "clear data browsing"
5. Click "Clear browsing data" in the pop-up window"
☆360 Browser
To clear the 360 cache, follow these steps:
1. Click the "Tools" menu at the top of the browser and select "IE options ".
2. In general, select Delete Browsing History.
3. Select the Internet temporary files check box.
4. Click Delete.
5. delete the file and click OK. Restart your browser ~~
How to clear the IE cache?
☆Ie6
1. Click the tool menu.
2. Select Internet.
3. Click the regular tab.
4. Click Delete file.
5. Click OK in the confirmation window.
6. Click OK to close the "Internet Options" window.
☆Ie 7
1. Click the tool menu. If you cannot find the menu, press the Alt key on the keyboard to display the menu.
2. Select Delete Browsing History.
3. Click Delete file.
4. Click the Yes button in the confirmation window.
5. Click Close.
☆I E8
1. Click the tool menu. If you cannot find the menu, press the Alt key on the keyboard to display the menu.
2. Select Delete Browsing History.
3. Select the Internet temporary files check box.
4. Click Delete.
5. delete the file and click OK.
☆Firefox
To clear the Mozilla Firefox cache, follow these steps:
1. Click the "Tools" menu at the top of the browser and select "Options ).
2. Click "Privacy ).
3. Click "Clear" next to "Cache ).
4. Click OK ).
☆Maxthon)
1. Click the "Tools" menu at the top of the browser and select "Internet Options ".
2. In general, select Delete Browsing History.
3. Select an Internet temporary file
4. delete the file and click Close.
☆Google chrome
To clear the chrome cache, follow these steps:
1. Click the small wrench icon.
2. Select "option"
3. Select "Personal Data"
4. In data browsing, click "clear data browsing"
5. Click "Clear browsing data" in the pop-up window"
☆360 Browser
To clear the 360 cache, follow these steps:
1. Click the "Tools" menu at the top of the browser and select "IE options ".
2. In general, select Delete Browsing History.
3. Select the Internet temporary files check box.
4. Click Delete.
5. delete the file and click OK. Restart your browser ~~