fix: add no-cache headers + remove debug console.logs
- Cache-Control/Pragma/Expires headers prevent browser caching of JS-heavy pages (fixes stale code after updates) - Removed debug console.log statements from upload handlers
This commit is contained in:
parent
6519fc1cf7
commit
1183059d8b
2 changed files with 5 additions and 3 deletions
|
|
@ -47,6 +47,10 @@ async def log_requests(request: Request, call_next):
|
||||||
logger.info("→ %s %s (body %s bytes)", request.method, request.url.path, cl)
|
logger.info("→ %s %s (body %s bytes)", request.method, request.url.path, cl)
|
||||||
try:
|
try:
|
||||||
response = await call_next(request)
|
response = await call_next(request)
|
||||||
|
# Prevent browser caching (especially important for JS-heavy pages)
|
||||||
|
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
|
||||||
|
response.headers["Pragma"] = "no-cache"
|
||||||
|
response.headers["Expires"] = "0"
|
||||||
return response
|
return response
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("← %s %s FAILED", request.method, request.url.path)
|
logger.exception("← %s %s FAILED", request.method, request.url.path)
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@ function toggleSourceInput(e) {
|
||||||
function setPhase(label, pct, isSpinner) {
|
function setPhase(label, pct, isSpinner) {
|
||||||
const el = document.getElementById('phase-label');
|
const el = document.getElementById('phase-label');
|
||||||
const fill = document.getElementById('progress-fill');
|
const fill = document.getElementById('progress-fill');
|
||||||
console.log('[setPhase] el:', !!el, 'fill:', !!fill, 'label:', label, 'pct:', pct);
|
|
||||||
if (el) el.innerHTML = (isSpinner ? '<span class="spinner"></span> ' : '') + label;
|
if (el) el.innerHTML = (isSpinner ? '<span class="spinner"></span> ' : '') + label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,8 +134,8 @@ async function handleUpload(formData) {
|
||||||
xhr.timeout = 7200000; // 2 hour timeout for very large uploads
|
xhr.timeout = 7200000; // 2 hour timeout for very large uploads
|
||||||
|
|
||||||
xhr.upload.addEventListener('progress', (e) => {
|
xhr.upload.addEventListener('progress', (e) => {
|
||||||
console.log('[upload] progress', e.loaded, e.total, e.lengthComputable);
|
|
||||||
if (e.lengthComputable) {
|
if (e.lengthComputable) {
|
||||||
|
const pct = Math.round((e.loaded / e.total) * 100);
|
||||||
setPhase('Uploading source file... ' + (e.loaded / (1024**3)).toFixed(1) + ' GiB', pct, false);
|
setPhase('Uploading source file... ' + (e.loaded / (1024**3)).toFixed(1) + ' GiB', pct, false);
|
||||||
} else {
|
} else {
|
||||||
// Fallback: show bytes uploaded even without total
|
// Fallback: show bytes uploaded even without total
|
||||||
|
|
@ -145,7 +144,6 @@ async function handleUpload(formData) {
|
||||||
});
|
});
|
||||||
|
|
||||||
xhr.addEventListener('loadstart', () => {
|
xhr.addEventListener('loadstart', () => {
|
||||||
console.log('[upload] loadstart');
|
|
||||||
setPhase('Uploading source file...', 0, true);
|
setPhase('Uploading source file...', 0, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue