Static files sent with Cache-Control: no-cache (revalidated, a 304 when unchanged): unversioned /vendor modules were cached heuristically, so a tablet kept the old mdi.mjs after the deploy that added the lock icons and the new icons.js failed to import from it, leaving a blank map
CI / check (push) Successful in 18s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-11-18 23:24:15 +01:00
1 parent f09216b102
commit a21e2b0bc6
2 files changed
+16

No files matched your search

+7
View File
@@ -54,6 +54,13 @@ module Maptool
class App < Sinatra::Base
set :public_folder, File.join(__dir__, "public")
# Revalidate every static file (a cheap 304 when unchanged): /js and
# /css are cache-busted by ASSET_VERSION below, but the /vendor modules
# they import (mdi.mjs, nps-symbols.mjs, ...) aren't versioned — with no
# Cache-Control a browser caches them heuristically for hours, and a
# deploy that adds an export there (mdi.mjs gaining a new icon) left a
# tablet with new icons.js + stale mdi.mjs: a failed import, a blank map.
set :static_cache_control, [:no_cache]
# The PWA manifest (public/manifest.webmanifest) — Rack doesn't know
# this extension and would serve it as application/octet-stream.
mime_type :webmanifest, "application/manifest+json"
+9
View File
@@ -34,6 +34,15 @@ class AppTest < Minitest::Test
end
end
# Unversioned /vendor modules must be revalidated, or a deploy adding an
# export to one (imported by a freshly versioned /js module) breaks a
# browser still holding the old copy — see static_cache_control in app.rb.
def test_static_files_are_revalidated
response = request.get("/vendor/mdi/mdi.mjs")
assert_equal 200, response.status
assert_includes response.headers["Cache-Control"], "no-cache"
end
def test_offline_tiles_reports_unavailable_when_no_pmtiles_present
response = request.get("/api/offline-tiles")
assert_equal({ "available" => false }, json_body(response))