Merge pull request 'fix(cinny-web): no-cache for the app shell on SPA routes; keep old hashed assets 14 days (#23)' (#30) from fix/shell-cache-and-assets into main
Lint / Shell (shellcheck) (push) Successful in 14s
Lint / JS (eslint) (push) Successful in 7s
Lint / No secrets in webhook configs (push) Successful in 3s
Lint / Landing page is rendered (matrix (push) Successful in 3s
Lint / Python (ruff) (push) Successful in 5s
Lint / Python deps (pip-audit) (push) Successful in 39s
Lint / Secret scan (gitleaks) (push) Successful in 9s
Lint / Shell (shellcheck) (push) Successful in 14s
Lint / JS (eslint) (push) Successful in 7s
Lint / No secrets in webhook configs (push) Successful in 3s
Lint / Landing page is rendered (matrix (push) Successful in 3s
Lint / Python (ruff) (push) Successful in 5s
Lint / Python deps (pip-audit) (push) Successful in 39s
Lint / Secret scan (gitleaks) (push) Successful in 9s
This commit was merged in pull request #30.
This commit is contained in:
@@ -160,7 +160,13 @@ echo "[$(date '+%Y-%m-%d %H:%M:%S')] Deploying to $WEBROOT..."
|
|||||||
# /var/www/html/config.json by lxc106-cinny.sh. The build ships a DEV default
|
# /var/www/html/config.json by lxc106-cinny.sh. The build ships a DEV default
|
||||||
# (allowCustomHomeservers:true); rsyncing it would clobber the production config
|
# (allowCustomHomeservers:true); rsyncing it would clobber the production config
|
||||||
# on every deploy. Keep the app bundle and the runtime config separate.
|
# on every deploy. Keep the app bundle and the runtime config separate.
|
||||||
rsync -a --delete --exclude config.json dist/ "$WEBROOT/"
|
# [matrix #23] Keep the previous builds' hashed assets for a while: a browser
|
||||||
|
# still holding an older index.html (or service-worker precache) asks for its
|
||||||
|
# assets/index-<old hash>.js, and deleting them on every deploy broke the app
|
||||||
|
# for those users until their cached shell expired. Prune after 14 days.
|
||||||
|
rsync -a --delete --exclude config.json --exclude assets/ dist/ "$WEBROOT/"
|
||||||
|
rsync -a dist/assets/ "$WEBROOT/assets/"
|
||||||
|
find "$WEBROOT/assets" -type f -mtime +14 -delete
|
||||||
|
|
||||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ===== Deploy complete ($VITE_APP_VERSION) ====="
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ===== Deploy complete ($VITE_APP_VERSION) ====="
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
# [matrix #23] SPA routes (/, /home/…, /login/…) are rewritten to /index.html
|
||||||
|
# inside `location /`, where no cache headers were set: browsers then reused a
|
||||||
|
# heuristically fresh shell after a deploy and requested deleted assets. Only
|
||||||
|
# the rewritten shell gets no-cache; other files there keep their defaults.
|
||||||
|
map $uri $lotus_shell_cache_control {
|
||||||
|
/index.html "no-cache, no-store, must-revalidate";
|
||||||
|
default "";
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
@@ -99,6 +108,9 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
# add_header here drops the server-level headers, so include them again.
|
||||||
|
include snippets/cinny-security-headers.conf;
|
||||||
|
add_header Cache-Control $lotus_shell_cache_control always;
|
||||||
rewrite ^/config\.json$ /config.json break;
|
rewrite ^/config\.json$ /config.json break;
|
||||||
rewrite ^/manifest\.json$ /manifest.json break;
|
rewrite ^/manifest\.json$ /manifest.json break;
|
||||||
rewrite ^/sw\.js$ /sw.js break;
|
rewrite ^/sw\.js$ /sw.js break;
|
||||||
|
|||||||
Reference in New Issue
Block a user