fix(api): Cache-Control no-store روی همهٔ پاسخ‌های API — دادهٔ کهنهٔ مرورگر علت دیدن نسخهٔ قدیمی مقاله‌ها بود

This commit is contained in:
aramesh-site deploy
2026-10-06 12:26:02 +00:00
parent 00e7490912
commit 27a9a82a37
+8
View File
@@ -45,6 +45,14 @@ async def _preview_noindex(request, call_next):
response.headers["X-Robots-Tag"] = "noindex, nofollow, noarchive"
return response
# پاسخ‌های API هرگز کش مرورگر/CDN نشوند — دادهٔ پنل بعد از هر ذخیره فوراً fresh بماند
@app.middleware("http")
async def _api_no_store(request, call_next):
response = await call_next(request)
if request.url.path.startswith("/api"):
response.headers["Cache-Control"] = "no-store"
return response
app.include_router(public.router, prefix="/api", tags=["عمومی"])
app.include_router(forms.router, prefix="/api", tags=["فرم‌ها"])
app.include_router(admin.auth_router, prefix="/api", tags=["احراز هویت"])