Merge pull request #812 from FenjuFu/fix/issue-810-spa-cache

fix(web): revalidate SPA entry point after upgrades
This commit is contained in:
XiaoSeS 2026-09-04 16:31:53 +08:00 committed by GitHub
commit 3364869b6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View file

@ -85,6 +85,16 @@ if [ "$index" != 'INDEX_HTML_MARKER' ]; then
exit 1
fi
# The SPA shell must revalidate on every navigation so a deployment upgrade
# cannot leave browsers referencing fingerprinted chunks from the old version.
cache_control=$(curl -fsS -o /dev/null -D - "$base/skillhub/dashboard" \
| awk 'tolower($1) == "cache-control:" { sub(/^[^:]*:[[:space:]]*/, ""); print }' \
| tr -d '\r')
if [ "$cache_control" != 'no-cache, must-revalidate' ]; then
echo "SPA routes must require revalidation, got Cache-Control: $cache_control" >&2
exit 1
fi
# Bare prefix redirects to the trailing-slash form.
code=$(curl -s -o /dev/null -w '%{http_code}' "$base/skillhub")
if [ "$code" != '301' ]; then

View file

@ -29,6 +29,7 @@ server {
include /etc/nginx/skillhub-base-path*.conf;
location / {
add_header Cache-Control "no-cache, must-revalidate" always;
try_files $uri $uri/ /index.html;
}