* don't mess with immutable request headers
* don't mess with requests outside the app (analytics, error tracking)
This commit is contained in:
parent
cdd22bed76
commit
eaf5d897ae
@ -30,7 +30,11 @@ self.addEventListener("message", (event) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener("fetch", (event) => {
|
self.addEventListener("fetch", (event) => {
|
||||||
if (event.request.headers.get("Accept") === "text/event-stream") {
|
const isSSERequest = event.request.headers.get("Accept") === "text/event-stream";
|
||||||
|
const isOutsideRequest = !["localhost", "dev.shellphone.app", "www.shellphone.app"].includes(
|
||||||
|
new URL(event.request.url).hostname,
|
||||||
|
);
|
||||||
|
if (isSSERequest || isOutsideRequest) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,6 @@ export function fetchLoaderData(event: FetchEvent): Promise<Response> {
|
|||||||
|
|
||||||
return caches.match(event.request, { cacheName: DATA_CACHE }).then((cachedResponse) => {
|
return caches.match(event.request, { cacheName: DATA_CACHE }).then((cachedResponse) => {
|
||||||
console.debug(`Serving data from ${cachedResponse ? "cache" : "network"}`, path);
|
console.debug(`Serving data from ${cachedResponse ? "cache" : "network"}`, path);
|
||||||
cachedResponse?.headers.set("X-Remix-Worker", "yes");
|
|
||||||
|
|
||||||
const timestamp = lastTimeRevalidated[path] ?? 0;
|
const timestamp = lastTimeRevalidated[path] ?? 0;
|
||||||
const diff = Date.now() - timestamp;
|
const diff = Date.now() - timestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user