From 91d6c8fb73cd83011aee828c89a3f81f0732c43a Mon Sep 17 00:00:00 2001 From: tc-imba Date: Wed, 26 Jun 2024 03:32:21 +0800 Subject: [PATCH] fix: cache problem (attempt 4) --- example/config.js | 2 +- .../{gatsby-browser.mjs => gatsby-browser.js} | 5 +++++ gatsby-theme-academic/{gatsby-ssr.mjs => gatsby-ssr.js} | 0 3 files changed, 6 insertions(+), 1 deletion(-) rename gatsby-theme-academic/{gatsby-browser.mjs => gatsby-browser.js} (71%) rename gatsby-theme-academic/{gatsby-ssr.mjs => gatsby-ssr.js} (100%) diff --git a/example/config.js b/example/config.js index cca921d7..07b0ebb6 100644 --- a/example/config.js +++ b/example/config.js @@ -8,7 +8,7 @@ module.exports = { introduction: [ 'You can write one or several paragraphs to introduce yourself here. You can find this introduction in the `config.js` file in the template.', 'In this site, almost everything supports Markdown Syntax. For example, you can add hyperlinks in the introduction such as [fxhsb](https://github.com/Reapor-Yurnero) with\n```markdown\n[fxhsb](https://github.com/Reapor-Yurnero)\n```', - 'Here we try to test whether reloading is enabled when site updated (2).', + 'Here we try to test whether reloading is enabled when site updated (3).', ], avatar: 'avatar.png', professions: [ diff --git a/gatsby-theme-academic/gatsby-browser.mjs b/gatsby-theme-academic/gatsby-browser.js similarity index 71% rename from gatsby-theme-academic/gatsby-browser.mjs rename to gatsby-theme-academic/gatsby-browser.js index a629fd1b..35cb970f 100644 --- a/gatsby-theme-academic/gatsby-browser.mjs +++ b/gatsby-theme-academic/gatsby-browser.js @@ -5,6 +5,11 @@ import { export const wrapPageElement = _wrapPageElement; // trigger an immediate page refresh when an update is found +export const onServiceWorkerUpdateFound = () => { + console.log('update found, reload the page'); + window.location.reload(); +}; + export const onServiceWorkerUpdateReady = () => { console.log('update found, reload the page'); window.location.reload(); diff --git a/gatsby-theme-academic/gatsby-ssr.mjs b/gatsby-theme-academic/gatsby-ssr.js similarity index 100% rename from gatsby-theme-academic/gatsby-ssr.mjs rename to gatsby-theme-academic/gatsby-ssr.js