Skip to content

Commit

Permalink
Prevent caching in startOver() function
Browse files Browse the repository at this point in the history
As the use of the `forceget` parameter in `window.location.reload()`
isn't supported in most browsers[1], a query string must be appended to the
location URL when refreshing the page. This commit adds a query string
made up of random characters.

[1]: https://developer.mozilla.org/en-US/docs/Web/API/Location/reload#forceget
  • Loading branch information
kohrVid committed Jan 29, 2024
1 parent 03379fc commit 84b2e08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export default function Home() {
}

const startOver = () => {
window.location.reload();
window.location = location.href + "?start-over=" +
(Math.random() + 1).toString(36).substring(2)
};

return (
Expand Down

0 comments on commit 84b2e08

Please sign in to comment.