Several ways to clean up your browser's Web cache (meta,form form, Ajax)

Source: Internet
Author: User
Tags html header

1.meta method

Add the HTML header

<meta http-equiv= "Pragma" content= "No-cache" >

Description: Prevents the browser from accessing page content from the local computer's cache. The above settings, visitors will not be able to browse offline.

<meta http-equiv= "Cache-control" content= "No-cache,must-revalidate" >

Description: Cache-control Specifies the caching mechanism that the request and response follows, No-cache indicates that the request or response message cannot be cached, must-revalidate, for each request from the client, the proxy server must want the server to verify that the cache is outdated;

<meta http-equiv= "Expires" content= "0" >

Description: Can be used to set the expiration time of a Web page. Once the page expires, it must be retransmitted to the server.

Together , you will be able to re-enter the page you have visited, the browser must download the latest content from the server to achieve the effect of the refresh.

2. Clean up the temporary cache of form forms

document.getElementById ("Yourformid"). Reset ();

Description: JS resets the form (reset) method.

Add the autocomplete= ' off ' attribute to the form, or add the autocomplete= ' off ' attribute to input

Description: Turns off auto-fill.

3.jquery--ajax clearing the cache

A. Use Ajax to request the latest server files, plus the request headers if-modified-since and Cache-control, as follows:

  $.ajax ({     URL:',     dataType:' json ',     beforesend:function  (xmlHttp) {         Xmlhttp.setrequestheader ("if-modified-since", "0");         Xmlhttp.setrequestheader ("Cache-control", "No-cache");     },     success:function  (response) {     }  });

B. Direct use of Cache:false

  $.ajax ({     URL:',     dataType:' json ',     Cache:false,      success: Function (response) {     }  });

C. Avoid caching with random numbers or random times

  $.ajax ({
Random number URL:' yoururl?ran= ' +math.random (), dataType:' json ', success: function(response) { } });
  $.ajax ({
Random time URL:new date (). GetTime (), dataType:' json ', success: function(response) { } });

Several ways to clean up your browser's Web cache (meta,form form, Ajax)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.