[PATCH] hgweb: support disabling page cache

Steven Stallion sstallion at gmail.com
Tue Apr 19 23:02:18 CDT 2011


# HG changeset patch
# User Steven Stallion <sstallion at gmail.com>
# Date 1303272110 14400
# Node ID 09c1266b7d19ac58bdef198965d44677c4021fa3
# Parent  94dbe11c15c38cdf7427079035cd83417636f3db
hgweb: support disabling page cache

By default, hgweb_mod supports caching via the ETag header. This can
cause some confusion with browsers which cache aggressively. This change
preserves existing behavior while giving the administrator a knob to
disable the ETag header.

diff -r 94dbe11c15c3 -r 09c1266b7d19 doc/hgrc.5.txt
--- a/doc/hgrc.5.txt	Tue Apr 19 23:37:06 2011 -0400
+++ b/doc/hgrc.5.txt	Wed Apr 20 00:01:50 2011 -0400
@@ -1042,6 +1042,8 @@
 
     To disable SSL verification temporarily, specify ``--insecure`` from
     command line.
+``cache``
+    Whether to support caching in hgweb. Defaults to True.
 ``contact``
     Name or email address of the person in charge of the repository.
     Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
diff -r 94dbe11c15c3 -r 09c1266b7d19 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Tue Apr 19 23:37:06 2011 -0400
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Apr 20 00:01:50 2011 -0400
@@ -188,7 +188,8 @@
                 req.form['cmd'] = [tmpl.cache['default']]
                 cmd = req.form['cmd'][0]
 
-            caching(self, req) # sets ETag header or raises NOT_MODIFIED
+            if self.configbool('web', 'cache', True):
+                caching(self, req) # sets ETag header or raises NOT_MODIFIED
             if cmd not in webcommands.__all__:
                 msg = 'no such method: %s' % cmd
                 raise ErrorResponse(HTTP_BAD_REQUEST, msg)


More information about the Mercurial-devel mailing list