Skip to content

Commit

Permalink
add purge cache
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanharikr committed Dec 5, 2024
1 parent 3a004fb commit 87c620b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="icon" href="light-favicon.png" media="(prefers-color-scheme: dark)" />
<link rel="stylesheet" href="https://cdn.hello.coop/css/hello-button.css" />
<script src="https://cdn.hello.coop/js/hello-dev-wc-footer.js" defer></script>
<script src="/purge-cache.js" defer></script>
<style type="text/css">
html,
body {
Expand Down
12 changes: 12 additions & 0 deletions public/purge-cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* If the browser back button is clicked, flush the cache.
* This ensures the user always sees an accurate and up-to-date view based on their state.
* Reference: https://stackoverflow.com/questions/8788802/prevent-safari-loading-from-cache-when-back-button-is-clicked
*/
(function () {
window.onpageshow = function (event) {
if (event.persisted) {
window.location.reload();
}
};
})();

0 comments on commit 87c620b

Please sign in to comment.