I am displaying animated GIF image as loader in the web page using below code. It's working fine. Loader image has animation which plays for 3 seconds and then stops and stays non-animated.
<style>
.content {display:none;}
.loader {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: url('../images/loader.gif?random=323527528432525.24234') 50% 50% no-repeat rgb(0,0,0, 0.90); }
</style>
<script>
setTimeout(function(){
$('.loader').css('display', 'none');
}, 5000);
</script>
Now, when page is loaded first time or reloaded using CTRL+F5
, animated GIF is displaying from start to end. For rest of the time, whenever page is refreshed, it just shows non-animated part of the loader image due to browser's caching.
To resolve caching issue, I have tried following things but no one is working.
#1 - I have attached random number as a query string after image name shown as below.
background: url('../images/loader.gif?random=1234.5678')
#2 - HTML headers to not to cache pages are mentioned as below:
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
Am I missing something more or else? Or is it not caching issue? Please advise.