mirror of
https://github.com/iflytek/skillhub.git
synced 2026-09-09 22:31:14 +00:00
Merge pull request #812 from FenjuFu/fix/issue-810-spa-cache
fix(web): revalidate SPA entry point after upgrades
This commit is contained in:
commit
3364869b6f
2 changed files with 11 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue