Stop caching index.html and speed up socket reconnect
Phones offer no easy hard-refresh, so a cached index.html kept serving an old bundle after a deploy (the live feed showed "reconnecting"). index.html and the SPA catch-all now send Cache-Control: no-store, while hashed /assets stay immutable. Also retry the first socket reconnect after 1s (was 2s) and surface the close code in the header so a failure is actionable on a phone.
This commit is contained in:
1 parent
6df44520fa
commit
c63753e592
3 files changed
+33
-6
No files matched your search
+10
-1
@@ -36,6 +36,7 @@ const events = ref([])
|
||||
const equityPoints = ref([])
|
||||
const busy = ref(false)
|
||||
const connected = ref(false)
|
||||
const socketError = ref('')
|
||||
|
||||
let socket
|
||||
let pollTimer
|
||||
@@ -132,8 +133,15 @@ onMounted(async () => {
|
||||
])
|
||||
socket = api.openSocket({
|
||||
onMessage: handleMessage,
|
||||
onOpen: () => (connected.value = true),
|
||||
onOpen: () => {
|
||||
connected.value = true
|
||||
socketError.value = ''
|
||||
},
|
||||
onClose: () => (connected.value = false),
|
||||
onError: (code) => {
|
||||
if (code === 1008) socketError.value = 'rejected by the server (token/auth)'
|
||||
else socketError.value = `socket closed (code ${code})`
|
||||
},
|
||||
})
|
||||
pollTimer = setInterval(refreshAll, 5000)
|
||||
})
|
||||
@@ -161,6 +169,7 @@ onUnmounted(() => {
|
||||
:class="connected ? 'bg-emerald-400' : 'bg-slate-500'"
|
||||
></span>
|
||||
{{ connected ? 'live' : 'reconnecting' }}
|
||||
<span v-if="!connected && socketError" class="text-amber-300">· {{ socketError }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-xs text-slate-400">
|
||||
|
||||
Reference in new issue
Block a user