0

I've created a simple HTML, SASS, JS website and each time im uploading new files, to actually see the changes appear on the website I need to clear my browsing data.

is there anyway to address it via vanilla js headers, or a button on the website to clear cache?

xarielah
  • 123
  • 2
  • 9

1 Answers1

0

You can create a button that deletes the cache for that page like this :

<button>Clear cache </button>
let btn = document.querySelector("button");
btn.addEventListener("click",()=>{
    window.location.reload(true);  
    window.location.reload();  // few browsers don't require for a parameter to be passed

})

To know more about window.location.reload(true)

Hritik Sharma
  • 1,756
  • 7
  • 24
  • The argument only works in Firefox. From your link: "However, in all other browsers, any parameter you specify in a location.reload() call will be ignored and have no effect of any kind." – Phix Mar 12 '22 at 08:30
  • Thank you for your answer Hritik Sharma, I'll try and apply that. Thank you for your addition Phix. – xarielah Mar 16 '22 at 15:15