pagecache: Add a debug header to indicate hits/misses.

To get the header in responses, be in debug mode or send
"Pragma: x-reddit-pagecache" in your request.
This commit is contained in:
Neil Williams
2013-05-08 17:16:17 -07:00
parent c5380a4e59
commit bf8750f32f

View File

@@ -805,6 +805,15 @@ class MinimalController(BaseController):
g.log.warning("Ignored exception (%r) on pagecache "
"write for %r", e, request.path)
pragmas = [p.strip() for p in
request.headers.get("Pragma", "").split(",")]
if g.debug or "x-reddit-pagecache" in pragmas:
if c.can_use_pagecache:
pagecache_state = "hit" if c.used_cache else "miss"
else:
pagecache_state = "disallowed"
response.headers["X-Reddit-Pagecache"] = pagecache_state
# send cookies
for k, v in c.cookies.iteritems():
if v.dirty: