fix(audio): eliminate browser media caching with timestamp cache-buster and HTTP no-cache headers

This commit is contained in:
DemonGatanjieu
2026-09-23 00:10:40 +08:00
parent 68ef786450
commit e6758759f2
6 changed files with 18 additions and 9 deletions
+9 -2
View File
@@ -76,6 +76,7 @@ def _scan_single_audio_dir(directory, relative_prefix=""):
file_size = os.path.getsize(full_path)
rel_path = os.path.join(relative_prefix, name).replace("\\", "/")
mtime = int(os.path.getmtime(full_path))
stem_map[stem] = {
"ext": ext,
"slice": {
@@ -87,7 +88,7 @@ def _scan_single_audio_dir(directory, relative_prefix=""):
"text": ref_text,
"size_bytes": file_size,
"syntax_tag": f"{{{stem}}}",
"audio_url": f"/anomalous/audio_stream?path={rel_path}"
"audio_url": f"/anomalous/audio_stream?path={rel_path}&v={mtime}"
}
}
return [item["slice"] for item in stem_map.values()]
@@ -163,7 +164,13 @@ async def api_serve_audio(request):
content_type = content_types.get(ext, 'application/octet-stream')
return web.FileResponse(
resolved_path,
headers={"Content-Type": content_type, "Accept-Ranges": "bytes"}
headers={
"Content-Type": content_type,
"Accept-Ranges": "bytes",
"Cache-Control": "no-store, no-cache, must-revalidate, max-age=0",
"Pragma": "no-cache",
"Expires": "0"
}
)
+1 -1
View File
@@ -6,7 +6,7 @@ try {
} catch (_) {}
import { app } from "../../scripts/app.js";
import { createBrowserEntry } from "./modules/browser_entry.js?v=20260921-flicker-free-1";
import { createBrowserEntry } from "./modules/browser_entry.js?v=20260923-nocache-1";
import { createInterfaceSettings, getCurrentLanguage, setAbyssalScarletTheme, t } from "./modules/interface_settings.js";
export { setAbyssalScarletTheme };
+2 -2
View File
@@ -21,8 +21,8 @@ import { showImageWorkbench } from './ui_gallery_detail.js';
import { initDoctorPanel, diagnoseNode, renderGlobalDashboard, openLoraInsertionPicker, runGlobalDoctorScan } from './ui_doctor.js';
import { initAssistantPanel, renderAssistantModelCard, _loadAssistantHistory } from './ui_node_assistant.js';
import { _openGalleryReplacer } from './ui_node_model_picker.js';
import { renderAudioStudio, stopAudioStudioPlayback } from './ui_audio_studio.js';
import { renderAudioGallery, stopGalleryAudio } from './ui_audio_gallery.js';
import { renderAudioStudio, stopAudioStudioPlayback } from './ui_audio_studio.js?v=20260923-cache-kill';
import { renderAudioGallery, stopGalleryAudio } from './ui_audio_gallery.js?v=20260923-cache-kill';
import { getActiveDomain } from './ui_domain_switcher.js';
export class AnomalousBrowser {
+2 -1
View File
@@ -73,7 +73,8 @@ function startPlayback(url, playBtn, fillEl, timeEl) {
}
stopGalleryAudio();
const audio = new Audio(url);
const freshUrl = url.includes('?') ? `${url}&_t=${Date.now()}` : `${url}?_t=${Date.now()}`;
const audio = new Audio(freshUrl);
activeAudio = audio;
activePlayBtn = playBtn;
activeProgressFill = fillEl;
+2 -1
View File
@@ -46,7 +46,8 @@ function playAudio(url, playBtn, eqBars) {
stopAudioStudioPlayback();
if (typeof stopGalleryAudio === 'function') stopGalleryAudio();
const audio = new Audio(url);
const freshUrl = url.includes('?') ? `${url}&_t=${Date.now()}` : `${url}?_t=${Date.now()}`;
const audio = new Audio(freshUrl);
globalAudioPlayer = audio;
currentPlayingBtn = playBtn;
currentPlayingBar = eqBars;
+2 -2
View File
@@ -12,8 +12,8 @@ import { createSettingsHub } from './ui_settings_hub.js';
import { createToolbox } from './ui_toolbox.js';
import { createDomainSwitcher, getActiveDomain } from './ui_domain_switcher.js';
import { renderAudioSidebar } from './ui_audio_sidebar.js';
import { renderAudioStudio } from './ui_audio_studio.js';
import { renderAudioGallery } from './ui_audio_gallery.js';
import { renderAudioStudio } from './ui_audio_studio.js?v=20260923-cache-kill';
import { renderAudioGallery } from './ui_audio_gallery.js?v=20260923-cache-kill';
const t = (key, params) => translate(key, params);