Wrap *body* in a Response with ETag + Cache-Control headers. The ETag is `` - `` — two deploy-wide constants, so it flips on any DB rebuild or code change and stays stable otherwise. Error paths don't go through this helper; they stay uncached. ``Vary
(body: str)
| 360 | |
| 361 | |
| 362 | def _cacheable_explain_response(body: str): |
| 363 | """Wrap *body* in a Response with ETag + Cache-Control headers. |
| 364 | |
| 365 | The ETag is ``<db_sha256[:16]>-<app_version>`` — two deploy-wide |
| 366 | constants, so it flips on any DB rebuild or code change and stays |
| 367 | stable otherwise. Error paths don't go through this helper; they |
| 368 | stay uncached. |
| 369 | |
| 370 | ``Vary: Accept-Encoding`` is set explicitly: we never emit |
| 371 | ``Set-Cookie`` and don't use Flask sessions, so cookies must not |
| 372 | enter CF's cache key. |
| 373 | """ |
| 374 | if current_app.config.get("DEBUG"): |
| 375 | return make_response(body) |
| 376 | response = make_response(body) |
| 377 | db_sha = current_app.config.get("DB_SHA256", "local") |
| 378 | app_ver = current_app.config.get("APP_VERSION", "local") |
| 379 | response.set_etag(f"{db_sha[:16]}-{app_ver}", weak=True) |
| 380 | response.headers["Cache-Control"] = _EXPLAIN_CACHE_CONTROL |
| 381 | response.headers["Vary"] = "Accept-Encoding" |
| 382 | response.make_conditional(request) |
| 383 | return response |
| 384 | |
| 385 | |
| 386 | def manpage_url(source): |
no outgoing calls
no test coverage detected