Make Etag support optional (in a first-class fashion).
* viewcvs/lib/viewcvs.py (check_freshness): Check the new configuration option for etag support. Also, cfg.general.http_expiration_time is now cfg.options.http_expiration_time. * viewcvs/lib/debug.py (DISABLE_ETAGS): Remove. * viewcvs/lib/config.py (Config.set_defaults): Set new 'generate_etags' option default to 1, and move 'http_expiration_time' to the [options] section (from the [general] one). * viewcvs/viewcvs.conf.dist (cfg.options.generate_etags): New. (cfg.options.http_expiration_time): Was cfg.general.http_expiration_time. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@865 8cb11bc2-c004-0410-86c3-e597b4017df7remotes/tags/1.0.0-rc1
parent
7b8eb7639e
commit
289c3b25bc
|
@ -162,7 +162,6 @@ class Config:
|
|||
self.general.forbidden = ()
|
||||
self.general.kv_files = [ ]
|
||||
self.general.languages = ['en-us']
|
||||
self.general.http_expiration_time = 600
|
||||
|
||||
self.templates.directory = 'templates/directory.ezt'
|
||||
self.templates.log = 'templates/log.ezt'
|
||||
|
@ -216,6 +215,8 @@ class Config:
|
|||
self.options.use_re_search = 0
|
||||
self.options.use_pagesize = 0
|
||||
self.options.use_localtime = 0
|
||||
self.options.http_expiration_time = 600
|
||||
self.options.generate_etags = 1
|
||||
|
||||
def is_forbidden(self, module):
|
||||
if not module:
|
||||
|
|
|
@ -21,7 +21,6 @@ import sys
|
|||
|
||||
SHOW_TIMES = 0
|
||||
SHOW_CHILD_PROCESSES = 0
|
||||
DISABLE_ETAGS = 0
|
||||
|
||||
if SHOW_TIMES:
|
||||
|
||||
|
|
|
@ -590,7 +590,7 @@ def _repos_pathtype(repos, path_parts):
|
|||
|
||||
def check_freshness(request, mtime=None, etag=None, weak=0):
|
||||
# See if we are supposed to disable etags (for debugging, usually)
|
||||
if debug.DISABLE_ETAGS:
|
||||
if not cfg.options.generate_etags:
|
||||
return 0
|
||||
|
||||
request_etag = request_mtime = None
|
||||
|
@ -618,12 +618,12 @@ def check_freshness(request, mtime=None, etag=None, weak=0):
|
|||
isfresh = 0
|
||||
|
||||
## require revalidation after 15 minutes ...
|
||||
if cfg and cfg.general.http_expiration_time >= 0:
|
||||
if cfg and cfg.options.http_expiration_time >= 0:
|
||||
expiration = rfc822.formatdate(time.time() +
|
||||
cfg.general.http_expiration_time)
|
||||
cfg.options.http_expiration_time)
|
||||
request.server.addheader('Expires', expiration)
|
||||
request.server.addheader('Cache-Control',
|
||||
'max-age=%d' % cfg.general.http_expiration_time)
|
||||
'max-age=%d' % cfg.options.http_expiration_time)
|
||||
|
||||
if isfresh:
|
||||
request.server.header(status='304 Not Modified')
|
||||
|
|
|
@ -249,18 +249,6 @@ languages = en-us
|
|||
# languages = de, fr, en-us
|
||||
#
|
||||
|
||||
#
|
||||
# This option sets the expiration time for cacheable pages served by
|
||||
# ViewCVS. Note that in most cases, a cache aware client will only
|
||||
# revalidate the page after it expires (using the If-Modified-Since
|
||||
# and/or If-None-Match headers) and that browsers will also revalidate
|
||||
# the page when the reload button is pressed. Set to 0 to disable the
|
||||
# transmission of these caching headers.
|
||||
#
|
||||
# Time is given in seconds.
|
||||
#
|
||||
http_expiration_time = 600
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
[templates]
|
||||
|
||||
|
@ -322,6 +310,20 @@ log = templates/log.ezt
|
|||
# 0 No special treatment of first path component (use root=)
|
||||
root_as_url_component = 0
|
||||
|
||||
# http_expiration_time: Expiration time (in seconds) for cacheable
|
||||
# pages served by ViewCVS. Note that in most cases, a cache aware
|
||||
# client will only revalidate the page after it expires (using the
|
||||
# If-Modified-Since and/or If-None-Match headers) and that browsers
|
||||
# will also revalidate the page when the reload button is pressed.
|
||||
# Set to 0 to disable the transmission of these caching headers.
|
||||
http_expiration_time = 600
|
||||
|
||||
# generate_etags: Generate Etag headers for relevant pages to assist
|
||||
# in browser caching.
|
||||
# 1 Generate Etags
|
||||
# 0 Don't generate Etags
|
||||
generate_etags = 1
|
||||
|
||||
# sort_by: File sort order
|
||||
# file Sort by filename
|
||||
# rev Sort by revision number
|
||||
|
|
|
@ -88,14 +88,20 @@
|
|||
"dir_header.ezt" and "dir_footer.ezt", also found in the
|
||||
"templates/include/" subdirectory.</p>
|
||||
|
||||
<p>Notably, both the "markup.ezt" and "annotate.ezt" templates are
|
||||
now fully self-contained. That is, the markup and annotation data
|
||||
<p>Notably, the "markup.ezt" and "annotate.ezt" templates are now
|
||||
fully self-contained. That is, the markup and annotation data
|
||||
generated by ViewCVS is now accessible in those templates just
|
||||
like other template variables. As a result, ViewCVS now has no
|
||||
more internal need for the <var>templates.footer</var>
|
||||
configuration variable, so that variable has been removed from the
|
||||
default configuration file.</p>
|
||||
|
||||
<h3>Configuration Options</h3>
|
||||
<p>
|
||||
Lots of options have been added. <i style="color:red;">### Need to
|
||||
document them.</i>
|
||||
</p>
|
||||
|
||||
<h3>Removed Template Variables</h3>
|
||||
<blockquote>
|
||||
<dl>
|
||||
|
@ -240,6 +246,14 @@
|
|||
</dt>
|
||||
<dd>New filesize variable for file directory entries.</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>
|
||||
<code>diff.ezt</code>:
|
||||
<var>raw_diff</var>
|
||||
</dt>
|
||||
<dd>New variable for testing and presenting the raw
|
||||
(non-colored) diff contents</dd>.
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>
|
||||
<code>annotate.ezt</code>:
|
||||
|
|
Loading…
Reference in New Issue