Conversation
Co-authored-by: theg1239 <theg1239@users.noreply.github.com>
…n-316e fix: avoid caching moderator pages
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds
Confidence Score: 3/5The missing trailing slash on the new prefix will cause the service worker to bypass the cache for any path starting with "/mod", not just the intended moderator routes. The single-character omission (no trailing slash on "/mod") means every path beginning with "/mod" — not just "/mod/" sub-routes — will be excluded from service worker caching. Depending on whether routes like "/modify" or "/module" exist or are added in the future, users could silently lose offline/cache support for those pages. public/sw.js — the new NO_CACHE_PATH_PREFIXES entry needs a trailing slash. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Fetch event] --> B{request.method === GET?}
B -- No --> Z[Pass through]
B -- Yes --> C{Parse URL}
C --> D{request.mode === navigate?}
D -- Yes --> E{isUncacheable?}
E -- Yes /mod* path --> Z
E -- No --> F[staleWhileRevalidate PAGE_CACHE]
D -- No --> G{isRoutePayloadRequest?}
G -- Yes --> H{isUncacheable?}
H -- Yes --> Z
H -- No --> I[networkOnly]
G -- No --> J{isSameOrigin or FONT_HOSTS?}
J -- No --> Z
J -- Yes --> K{isUncacheable?}
K -- Yes /mod* path --> Z
K -- No --> L{isStaticAsset?}
L -- Yes --> M[cacheFirst STATIC_CACHE]
L -- No --> N{isHtmlAccept?}
N -- Yes --> O[staleWhileRevalidate PAGE_CACHE]
N -- No --> P[staleWhileRevalidate RUNTIME_CACHE]
Reviews (1): Last reviewed commit: "Merge pull request #432 from ACM-VIT/cur..." | Re-trigger Greptile |
| "/_next/image", | ||
| "/signin", | ||
| "/ecp/", | ||
| "/mod", |
There was a problem hiding this comment.
The
/mod prefix lacks a trailing slash, so isUncacheable() (which uses startsWith) will bypass the cache for any path beginning with /mod — including unrelated routes like /modify, /models, /module, etc. Every other route-level prefix in this array uses a trailing slash (e.g. /ecp/, /api/, /auth/) specifically to prevent this. Add the slash to scope the exclusion to only /mod and its sub-paths.
| "/mod", | |
| "/mod/", |
| "/_next/image", | ||
| "/signin", | ||
| "/ecp/", | ||
| "/mod", |
There was a problem hiding this comment.
Commit message "sync" is not descriptive — it gives no context about why
/mod is being excluded from caching. A message like "feat(sw): skip cache for /mod moderator routes" would make the intent clear at a glance in the git log and help future contributors understand which routes the service worker bypasses.
Context Used: Encourage people to write better commit messages (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
No description provided.