Preview cache-busting: Cache-Control: no-cache na endpoint + ?v=Date.now() v frontend URL — browser ne sme cachat starega output-a po recutu
This commit is contained in:
parent
c1e00b7b73
commit
7a7d7ea20d
@ -1521,6 +1521,7 @@ async def preview(job_id: str, request: Request, user: str = Depends(check_auth)
|
||||
"Accept-Ranges": "bytes",
|
||||
"Content-Length": str(chunk_size),
|
||||
"Content-Type": "video/mp4",
|
||||
"Cache-Control": "no-cache, must-revalidate", # browser ne sme cachat starega output-a
|
||||
}
|
||||
return StreamingResponse(iter_file(), status_code=206, headers=headers,
|
||||
media_type="video/mp4")
|
||||
@ -1531,7 +1532,11 @@ async def preview(job_id: str, request: Request, user: str = Depends(check_auth)
|
||||
return FileResponse(
|
||||
out,
|
||||
media_type="video/mp4",
|
||||
headers={"Accept-Ranges": "bytes", "Content-Length": str(file_size)},
|
||||
headers={
|
||||
"Accept-Ranges": "bytes",
|
||||
"Content-Length": str(file_size),
|
||||
"Cache-Control": "no-cache, must-revalidate", # browser ne sme cachat starega output-a
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -1773,15 +1773,17 @@
|
||||
|
||||
function previewJob(id, title) {
|
||||
// Odpre velik modal z reel videom
|
||||
// Dodaj timestamp cache-buster da browser ne servira starega cached output-a
|
||||
const cacheBust = Date.now();
|
||||
const overlay = document.createElement("div");
|
||||
overlay.className = "modal-overlay";
|
||||
overlay.innerHTML = `
|
||||
<div class="modal-content" onclick="event.stopPropagation()">
|
||||
<button class="modal-close" title="Zapri (ESC)">×</button>
|
||||
<video src="/api/preview/${id}" controls autoplay playsinline></video>
|
||||
<video src="/api/preview/${id}?v=${cacheBust}" controls autoplay playsinline></video>
|
||||
${title ? `<div class="modal-title">${title}</div>` : ""}
|
||||
<div class="modal-actions">
|
||||
<button class="primary" onclick="window.open('/api/download/${id}')">⬇ Prenesi reel</button>
|
||||
<button class="primary" onclick="window.open('/api/download/${id}?v=${cacheBust}')">⬇ Prenesi reel</button>
|
||||
<button onclick="closeModal()">Zapri</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user