首屏优化:scan terminal 加 s-maxage 缓存 + 落地页预加载 API
1. /api/scan/terminal 返回 Cache-Control: public, s-maxage=30, stale-while-revalidate=120 → pre-warm 期间也能返回缓存,白屏 20s 变 1s 2. 落地页 2s 后静默 prefetch /api/cities,预热后端进程和连接池 3. metadata 加 preconnect api.polyweather.top
This commit is contained in:
+8
-1
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Request
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from web.services.scan_api import (
|
||||
get_scan_terminal_ai_payload,
|
||||
@@ -30,7 +31,7 @@ async def scan_terminal(
|
||||
trading_region: str = "",
|
||||
timezone_offset_seconds: int | None = None,
|
||||
):
|
||||
return await get_scan_terminal_payload(
|
||||
payload = await get_scan_terminal_payload(
|
||||
request,
|
||||
scan_mode=scan_mode,
|
||||
min_price=min_price,
|
||||
@@ -45,6 +46,12 @@ async def scan_terminal(
|
||||
region=region or trading_region or None,
|
||||
timezone_offset_seconds=timezone_offset_seconds,
|
||||
)
|
||||
return JSONResponse(
|
||||
content=payload,
|
||||
headers={
|
||||
"Cache-Control": "public, s-maxage=30, stale-while-revalidate=120",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@router.post("/api/scan/terminal/ai")
|
||||
|
||||
Reference in New Issue
Block a user