fix(api): Cache-Control no-store روی همهٔ پاسخهای API — دادهٔ کهنهٔ مرورگر علت دیدن نسخهٔ قدیمی مقالهها بود
This commit is contained in:
@@ -45,6 +45,14 @@ async def _preview_noindex(request, call_next):
|
|||||||
response.headers["X-Robots-Tag"] = "noindex, nofollow, noarchive"
|
response.headers["X-Robots-Tag"] = "noindex, nofollow, noarchive"
|
||||||
return response
|
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(public.router, prefix="/api", tags=["عمومی"])
|
||||||
app.include_router(forms.router, prefix="/api", tags=["فرمها"])
|
app.include_router(forms.router, prefix="/api", tags=["فرمها"])
|
||||||
app.include_router(admin.auth_router, prefix="/api", tags=["احراز هویت"])
|
app.include_router(admin.auth_router, prefix="/api", tags=["احراز هویت"])
|
||||||
|
|||||||
Reference in New Issue
Block a user