fix: 修復 /health 端點瀏覽器快取導致前端顯示過時更新時間
- 後端 /health 端點加入 Cache-Control no-cache 標頭 - 前端 fetch 呼叫加入 cache: 'no-store' 選項 - 修復 portal.html 無效的 timeout 選項 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ Provides /health endpoint for monitoring service status.
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from flask import Blueprint, jsonify
|
||||
from flask import Blueprint, jsonify, make_response
|
||||
|
||||
from mes_dashboard.core.database import get_engine
|
||||
from mes_dashboard.core.redis_client import (
|
||||
@@ -190,4 +190,9 @@ def health_check():
|
||||
if warnings:
|
||||
response['warnings'] = warnings
|
||||
|
||||
return jsonify(response), http_code
|
||||
# Add no-cache headers to prevent browser caching
|
||||
resp = make_response(jsonify(response), http_code)
|
||||
resp.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
|
||||
resp.headers['Pragma'] = 'no-cache'
|
||||
resp.headers['Expires'] = '0'
|
||||
return resp
|
||||
|
||||
@@ -451,7 +451,7 @@
|
||||
|
||||
async function checkHealth() {
|
||||
try {
|
||||
const response = await fetch('/health', { timeout: 10000 });
|
||||
const response = await fetch('/health', { cache: 'no-store' });
|
||||
const data = await response.json();
|
||||
|
||||
// Update main indicator
|
||||
|
||||
@@ -1570,7 +1570,7 @@
|
||||
|
||||
async function checkCacheStatus() {
|
||||
try {
|
||||
const resp = await fetch('/health');
|
||||
const resp = await fetch('/health', { cache: 'no-store' });
|
||||
const data = await resp.json();
|
||||
|
||||
const dot = document.getElementById('cacheDot');
|
||||
|
||||
Reference in New Issue
Block a user