MCPcopy Index your code
hub / github.com/idank/explainshell / _cacheable_explain_response

Function _cacheable_explain_response

explainshell/web/views.py:362–383  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

360
361
362def _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&#x27;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&#x27;t use Flask sessions, so cookies must not
372 enter CF&#x27;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
386def manpage_url(source):

Callers 3

indexFunction · 0.85
_handle_explain_cmdFunction · 0.85
_handle_explain_programFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected