Add xkey headers to outgoing emails
authorMagnus Hagander <magnus@hagander.net>
Tue, 18 Jun 2019 12:24:06 +0000 (14:24 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 18 Jun 2019 12:25:01 +0000 (14:25 +0200)
Instead of just our own x-pglm and x-pgthread, add specific xkey
headers. These are used by our Varnish frontends to purge more
efficiently.

For the time being, leave the older headers in place -- we need to have
the entire contents of the cache containing xkey headers before we can
start using xkey for purging, and only once that is done we will be able to
remove the non-xkey headers.

django/archives/mailarchives/api.py
django/archives/mailarchives/views.py

index c0bced3ac0bc3c0483bebaeaff22e2f11038eb31..0b5021de030de33f4951cb2b9dd235e75a8c721a 100644 (file)
@@ -86,6 +86,7 @@ def latest(request, listname):
     # XXX: need to deal with the global view, but for now API callers come in directly
     if list:
         resp['X-pglm'] = ':%s:' % (':'.join(['%s/%s/%s' % (list.listid, year, month) for year, month in allyearmonths]))
+        resp['xkey'] = ' '.join(['pgam_{0}/{1}/{2}'.format(l.listid, year, month) for year, month in allyearmonths])
     return resp
 
 
@@ -113,6 +114,7 @@ def thread(request, msgid):
         }
         for m in mlist], resp)
     resp['X-pgthread'] = msg.threadid
+    resp['xkey'] = 'pgat_{0}'.format(msg.threadid)
     return resp
 
 
index f19329f479dd5d4233d8256b68416aabcea64781..203bd68f82d67998584175447eae10565a20ac8f 100644 (file)
@@ -286,6 +286,7 @@ def _render_datelist(request, l, d, datefilter, title, queryproc):
         'yearmonth': yearmonth,
     })
     r['X-pglm'] = ':%s:' % (':'.join(['%s/%s/%s' % (l.listid, year, month) for year, month in allyearmonths]))
+    r['xkey'] = ' '.join(['pgam_{0}/{1}/{2}'.format(l.listid, year, month) for year, month in allyearmonths])
     return r
 
 
@@ -491,6 +492,7 @@ def message(request, msgid):
         'nextprev': nextprev,
     })
     r['X-pgthread'] = ":%s:" % m.threadid
+    r['xkey'] = 'pgat_{0}'.format(m.threadid)
     r['Last-Modified'] = http_date(newest)
     return r
 
@@ -521,6 +523,7 @@ def message_flat(request, msgid):
         'isfirst': isfirst,
     })
     r['X-pgthread'] = ":%s:" % msg.threadid
+    r['xkey'] = 'pgat_{0}'.format(msg.threadid)
     r['Last-Modified'] = http_date(newest)
     return r
 
@@ -543,6 +546,7 @@ def message_raw(request, msgid):
     else:
         r = HttpResponse(row[0][2], content_type='text/plain')
         r['X-pgthread'] = ":%s:" % row[0][0]
+        r['xkey'] = 'pgat_{0}'.format(row[0][0])
     return r