ops design and app
add more comments feature, more tags feature, and other frontend updates
This commit is contained in:
@@ -9,6 +9,7 @@ const STATIC_ASSETS = [
|
||||
"/static/realtime.js",
|
||||
"/static/editor.js",
|
||||
"/static/render.js",
|
||||
"/static/tags.js",
|
||||
"/static/favicon.png",
|
||||
"/static/cairnquire%20logo%402x.webp",
|
||||
"/",
|
||||
@@ -64,12 +65,13 @@ self.addEventListener("fetch", function (event) {
|
||||
});
|
||||
|
||||
async function handleNavigation(request, url) {
|
||||
const cacheKey = url.pathname + url.search;
|
||||
try {
|
||||
const response = await fetch(request);
|
||||
cachePageResponse(url.pathname, response.clone());
|
||||
cachePageResponse(cacheKey, response.clone());
|
||||
return response;
|
||||
} catch (_error) {
|
||||
const cachedPage = await getCachedPage(url.pathname);
|
||||
const cachedPage = await getCachedPage(cacheKey);
|
||||
if (cachedPage && cachedPage.html) {
|
||||
return new Response(markOfflineHTML(cachedPage.html), {
|
||||
headers: {
|
||||
@@ -80,6 +82,19 @@ async function handleNavigation(request, url) {
|
||||
});
|
||||
}
|
||||
|
||||
if (cacheKey !== "/") {
|
||||
const fallback = await getCachedPage("/");
|
||||
if (fallback && fallback.html) {
|
||||
return new Response(markOfflineHTML(fallback.html), {
|
||||
headers: {
|
||||
"Content-Type": "text/html; charset=utf-8",
|
||||
"X-MDHub-Cache": "offline",
|
||||
},
|
||||
status: 200,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const fallback = await caches.match("/");
|
||||
if (fallback) {
|
||||
return fallback;
|
||||
|
||||
Reference in New Issue
Block a user