Compare commits

..

3 commits

Author SHA1 Message Date
yuuki
fb84e2f8f0 キャッシュの調整 2025-01-31 16:51:57 +09:00
yuuki
389b1a8320 chart.jsの更新 2025-01-31 16:51:45 +09:00
yuuki
4f136cff5b fastapiを更新 2025-01-31 16:48:32 +09:00
3 changed files with 10 additions and 12 deletions

14
app.py
View file

@ -72,12 +72,11 @@ async def cloudflare(zone_id: str, x_token: Union[str, None] = Header()):
json = result.json() json = result.json()
res = JSONResponse(json) res = JSONResponse(json)
if "data" in json and not json["errors"]: if "data" in json and not json["errors"]:
res.headers["Cache-Control"] = f"public, max-age=60, s-maxage=60" pass
res.headers["CDN-Cache-Control"] = f"max-age=60"
else: else:
res.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR res.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
res.headers["Cache-Control"] = f"public, max-age=0, s-maxage=0" res.headers["Cache-Control"] = f"public, max-age=15, s-maxage=15"
res.headers["CDN-Cache-Control"] = f"max-age=0" res.headers["CDN-Cache-Control"] = f"max-age=15"
return res return res
@app.get("/api/cloudflare2") @app.get("/api/cloudflare2")
@ -106,12 +105,11 @@ async def cloudflare2(zone_id: str, x_token: Union[str, None] = Header()):
json = result.json() json = result.json()
res = JSONResponse(json) res = JSONResponse(json)
if "data" in json and not json["errors"]: if "data" in json and not json["errors"]:
res.headers["Cache-Control"] = f"public, max-age=60, s-maxage=60" pass
res.headers["CDN-Cache-Control"] = f"max-age=60"
else: else:
res.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR res.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
res.headers["Cache-Control"] = f"public, max-age=0, s-maxage=0" res.headers["Cache-Control"] = f"public, max-age=15, s-maxage=15"
res.headers["CDN-Cache-Control"] = f"max-age=0" res.headers["CDN-Cache-Control"] = f"max-age=15"
return res return res
@app.get("/") @app.get("/")

View file

@ -1,2 +1,2 @@
requests==2.32.3 requests==2.32.3
fastapi[standard]==0.115.7 fastapi[standard]==0.115.8

File diff suppressed because one or more lines are too long