Add commit-hash-based cache busting to PWA service worker#3
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Agent-Logs-Url: https://github.com/rorpage/autoplay/sessions/db738686-2743-45f2-8b83-bd2d084d9fc5 Co-authored-by: rorpage <1423093+rorpage@users.noreply.github.com>
|
@copilot I'm deploying to Vercel so I don't need the Action. If we can inject the commit hash into the service worker that should suffice right? |
Agent-Logs-Url: https://github.com/rorpage/autoplay/sessions/89aa106e-78f3-4217-a9de-ab3c6ebeb486 Co-authored-by: rorpage <1423093+rorpage@users.noreply.github.com>
Yes, that's exactly right. I've removed the GitHub Actions workflow and replaced it with a {
"buildCommand": "bash -c \"sed -i 's/__COMMIT_HASH__/'${VERCEL_GIT_COMMIT_SHA:0:7}'/g' sw.js\"",
"outputDirectory": "."
}Vercel exposes |
|
@copilot Mark this as not draft and let's get it committed and pushed |
I'm unable to convert the draft status from this environment due to API permissions. You can mark it ready for review by clicking the "Ready for review" button at the bottom of the PR page on GitHub. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
PWA users were stuck on stale cached assets indefinitely — the service worker used a hardcoded cache key (
states-tracker-v1) with no invalidation on deploy.Changes
sw.js__COMMIT_HASH__placeholder, yielding names likestates-tracker-60c280cper deployactivatehandler to purge all caches not matching the current versionvercel.json(new)__COMMIT_HASH__with the first 7 characters ofVERCEL_GIT_COMMIT_SHA(Vercel's built-in env var) viasedbefore the files are servedoutputDirectoryto.so the project root is served as-is after the substitution📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.