• Preventing Caching in JQuery Ajax requests

    by Venkata Koppaka | Sep 23, 2010
    To prevent Caching of results while making JQuery Ajax requests use the following code -
    1         <script type="text/javascript"> 
    2             $(function() { 
    3                 $.ajaxSetup({ cache: false }); // prevent caching of get requests (needed for IE). 
    4             }); 
    5         </script> 

    If you use the above script, whenever you make a JQuery ajax request it will auto-add a unique URL parameter to the requestedy url and hence the cached results wont be returned.

    Here is how a JQuery GET request would look like without cache : false


    Here is how JQuery GET request would look like with cache : false.

     

    Hope this helps,

    Cheers,

    Venkata

    Go comment!