Click here to Skip to main content
15,867,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Im changing the background image of an application which should change in clients browsers too.But the updated image is displayed as the image loading from cache.I want to load it from web server.When i do cntrl+5 page is loading from server.If anyone knows the solution please help me out.
Thanks

What I have tried:

I have tried many syntax to hard reload the page.
ex:location.reload(true);
window.location.href = window.location.href;
These syntax are not all working.Looks like it got deprecated.
Posted
Updated 14-Jul-20 21:13pm
Comments
Peter_in_2780 15-Jul-20 0:59am    
At least the first three results from searching "javascript reload page" tell you exactly how.
Nagavarsha Jasti 15-Jul-20 14:01pm    
yes, but it wont work

1 solution

Most of your url reload functions has been deprecated.

You can change your header metatags -
HTML
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1"/>


Another option would be to use Clear-Site-Data -

HTML
// Single directive
Clear-Site-Data: "cache"

// Multiple directives (comma separated)
Clear-Site-Data: "cache", "cookies"

// Wild card
Clear-Site-Data: "*"


or you can use the Cache.delete() function -

HTML
caches.open('v1').then(function(cache) {
  cache.delete('/images/image.png').then(function(response) {
    someUIUpdateFunction();
  });
})


Keep in mind however that cache is there for a reason to increase your page loading performance, so this will clear your users cache every time the code is executed, slowing down the page load.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900