mable george
mable george

Reputation: 223

IE stores data in cache, changes not reflecting in jQuery

IE stored the data in cache and even if there are changes, its not reflecting onclick. But when I open the developer mode and try to access the same, then it works perfectly. In all other browsers its fine.

Other weird thing its working properly in local setup, it has issue in production. I have already use the meta tags:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

But no hope. Can any one please help?

Here is my jQuery:

        function showSubjectItems(){

            var dis = $("#myTopic").css('display');

            if(dis == 'none'){

                $("#myTopic").css({display: 'block'}).animate({ opacity: 1 }, 100, function(){

                    pleasewait();

                    $("#myTopic").empty().load("mygroupmessagesItem.xhtml"); 

                }); 


            }else{

                $("#myTopic").css({display: 'none'}).animate({ opacity: 1 }, 100, function(){

                    $("#myTopic").empty();

                });

            }

        }

Upvotes: 1

Views: 372

Answers (1)

Sahil Bhardwaj
Sahil Bhardwaj

Reputation: 345

Add this code inside your scripts to prevent caching of ajax calls

$(document).ready(function() {
  $.ajaxSetup({ cache: false });
});

If this doesn't work then code below will definitely work.

$("#myTopic").empty().load("mygroupmessagesItem.xhtml?random="+Math.random());

appending a random value as parameter to URL will not prevent result from loading from cache, give it a try. Upvote if it helps.

Upvotes: 1

Related Questions