-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Docs][Bug]: using offline pages #79
Comments
Sorry for the late reply. I'm currently focused on Serwist 9.0.0, so things can escape my attention at times. Before I go into the details, I just want to say that you've got to brush up on that English 💀 Quoting jeffposnick here:
To implement a fallback page with Serwist, do this instead: // Anything random.
const revision = crypto.randomUUID();
installSerwist({
precacheEntries: self.__SW_MANIFEST,
skipWaiting: true,
clientsClaim: true,
navigationPreload: true,
runtimeCaching: defaultCache,
fallbacks: {
entries: [
{
url: "/~offline",
revision,
matcher({ request }) {
// Or whatever else you want to check for in a request.
return request.destination === "document";
},
},
],
},
});
Now this brought to my attention something else related. Turns out our |
This issue is stale because it has been open for 30 days with no activity. |
@DuCanhGH thank you for your explanation. I probably don't understand something Here is my config: import {defaultCache} from '@serwist/next/browser';
import {installSerwist} from '@serwist/sw';
import type {PrecacheEntry} from '@serwist/precaching';
declare const self: ServiceWorkerGlobalScope & {
// Change this attribute's name to your `injectionPoint`.
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
};
// Anything random.
const revision = crypto.randomUUID();
installSerwist({
precacheEntries: self.__SW_MANIFEST,
skipWaiting: true,
clientsClaim: true,
navigationPreload: true,
runtimeCaching: defaultCache,
fallbacks: {
entries: [
{
url: '/offline.html',
revision,
matcher({request}) {
return request.destination === 'document';
}
}
]
}
}); I open my website, it loads stuff and generates a lot of messages in the console with cache hits/misses etc. Then I go to Web Developer tools, put Network to Offline and type some random path, i.e. http://localhost:3000/non-existing-path. What happens is that it loads the main page (instead of |
@mdevils can you verify if "/offline.html" was properly cached? Thanks! Also, you may want to check if |
This issue is stale because it has been open for 30 days with no activity. |
Provide environment information
this is my sw.js
Describe the problem
I wanted to add an offline page in all cases the navigation fallback requires things be preloaded
debuging I noticed that
__SW_MANIFEST
is undefined during developmentso I manually added an entry for the offline page
this worked
except that both in development and during build
if I navigate to the a page using the browser url
I always get the offline page rendered
If I navigate using the navbar available to another page they work
I don't know how to setup offline
Expected behavior
I'm expecting that if I add a navigation fallback that it gets pre-cached in general on it's own
and I'm expecting it to show only when I'm offline
Screenshots (if relevant)
this is working correct I am indeed offline
If I'm online and navigate internally I can see the pages
But if I refresh the request to page is intercepted and offline is rendered, you can see that only that one request fails
Additional information (if relevant)
No response
The text was updated successfully, but these errors were encountered: