mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 03:36:48 +00:00
fix(nginx): browsers revalidate static files
Static URLs carry no version, but nginx served them with expires max, so after an update or a theme change browsers kept the old CSS and JS. They now revalidate each load (304 when unchanged). CI checks the header, the 304 and that a changed file is sent again.
This commit is contained in:
parent
d4f04cbf1e
commit
0906838193
3 changed files with 22 additions and 1 deletions
18
.github/workflows/test.yml
vendored
18
.github/workflows/test.yml
vendored
|
|
@ -156,6 +156,24 @@ jobs:
|
|||
- name: Import Compiled Dependencies
|
||||
run: docker exec wvc /srv/webvirtcloud/venv/bin/python3 -c "import libvirt, ldap, lxml.etree, psycopg, sass"
|
||||
|
||||
# Static URLs carry no version: browsers must revalidate them
|
||||
- name: Static Files Revalidated
|
||||
run: |
|
||||
url=http://127.0.0.1:8080/static/css/wvc-main.min.css
|
||||
header() { tr -d '\r' | awk -v h="$1" 'tolower($0) ~ "^" h ":" {sub(/^[^:]*: */, ""); print}'; }
|
||||
h=$(curl -s -m 5 -D - -o /dev/null "$url")
|
||||
[ "$(echo "$h" | header cache-control)" = no-cache ] || { echo "$h"; exit 1; }
|
||||
etag=$(echo "$h" | header etag)
|
||||
[ -n "$etag" ]
|
||||
h=$(curl -s -m 5 -D - -o /dev/null -H "If-None-Match: $etag" "$url")
|
||||
echo "$h" | head -1 | grep -q " 304" || { echo "$h"; exit 1; }
|
||||
[ "$(echo "$h" | header cache-control)" = no-cache ]
|
||||
docker exec wvc sh -c 'echo "/* changed */" >> /srv/webvirtcloud/staticfiles/css/wvc-main.min.css'
|
||||
h=$(curl -s -m 5 -D - -o /dev/null -H "If-None-Match: $etag" "$url")
|
||||
echo "$h" | head -1 | grep -q " 200" || { echo "$h"; exit 1; }
|
||||
new=$(echo "$h" | header etag)
|
||||
[ -n "$new" ] && [ "$new" != "$etag" ]
|
||||
|
||||
# The browser reaches the console through nginx on the panel's port
|
||||
- name: Console Through Nginx Only
|
||||
run: |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue