function clearCacheAndCookies() { // Clear cookies document.cookie.split(";").forEach(function(c) { document.cookie = c.trim().split("=")[0] + "=;expires=" + new Date(0).toUTCString() + ";path=/"; }); // Clear localStorage and sessionStorage localStorage.clear(); sessionStorage.clear(); // Reload the page to clear cache location.reload(true); } // Run the function automatically on page load clearCacheAndCookies();