summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorville <ville@localhost>2009-10-24 15:59:18 +0000
committerville <ville@localhost>2009-10-24 15:59:18 +0000
commitd678b0b76e0b07fcda44af27fac0d02f3dfbe63c (patch)
treeeb50ed4b99cd6065504d9082d23ac636e04ffbd1
parente901993d2506ee76d262343d970706029d619e5f (diff)
downloadmarkup-validator-d678b0b76e0b07fcda44af27fac0d02f3dfbe63c.zip
markup-validator-d678b0b76e0b07fcda44af27fac0d02f3dfbe63c.tar.gz
markup-validator-d678b0b76e0b07fcda44af27fac0d02f3dfbe63c.tar.bz2
Add option to use file based template caching. Doing it in non-mod_perl
environments results in a noticeable performance improvement.
-rw-r--r--htdocs/config/validator.conf10
-rwxr-xr-xhttpd/cgi-bin/check18
2 files changed, 22 insertions, 6 deletions
diff --git a/htdocs/config/validator.conf b/htdocs/config/validator.conf
index 2853e28..61a761c 100644
--- a/htdocs/config/validator.conf
+++ b/htdocs/config/validator.conf
@@ -1,7 +1,7 @@
# Main Configuration File for the W3C Markup Validation Service.
#
-# $Id: validator.conf,v 1.37 2009-09-16 19:15:19 ville Exp $
+# $Id: validator.conf,v 1.38 2009-10-24 15:59:18 ville Exp $
#
# See 'perldoc Config::General' for the syntax, and be aware that the
# 'SplitPolicy' is 'equalsign', ie. keys and values are separated by '\s*=\s*',
@@ -27,6 +27,14 @@
# Location of template files
Templates = $Base/share/templates
+ #
+ # Directory where to store cached templates. Relative paths are
+ # treated as relative to the system temporary directory. Templates
+ # are not cached at all if this option is empty or not set, except
+ # with mod_perl setups where this option has no effect and templates
+ # are always cached in memory.
+ #Cache = validator
+
# configuration file for HTML Tidy Module, if available
TidyConf = $Base/htdocs/config/tidy.conf
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check
index b2395e5..5a1c515 100755
--- a/httpd/cgi-bin/check
+++ b/httpd/cgi-bin/check
@@ -14,7 +14,7 @@
# This source code is available under the license at:
# http://www.w3.org/Consortium/Legal/copyright-software
#
-# $Id: check,v 1.715 2009-10-23 20:46:13 ville Exp $
+# $Id: check,v 1.716 2009-10-24 15:59:18 ville Exp $
#
# Disable buffering on STDOUT!
$| = 1;
@@ -51,7 +51,7 @@ use Encode qw();
use Encode::Alias qw();
use Encode::HanExtra qw(); # for some chinese character encodings,
# e.g gb18030
-use File::Spec::Functions qw(catfile);
+use File::Spec::Functions qw(catfile rel2abs tmpdir);
use HTML::Encoding 0.52 qw();
use HTML::Parser 3.24 qw(); # Need 3.24 for $p->parse($code_ref)
use HTML::Template 2.6 qw(); # Need 2.6 for path param, other things.
@@ -119,7 +119,8 @@ BEGIN {
-DefaultConfig => {
Protocols => {Allow => 'http,https'},
Paths => {
- Base => ($ENV{W3C_VALIDATOR_HOME} || '/usr/local/validator'),
+ Base => ($ENV{W3C_VALIDATOR_HOME} || '/usr/local/validator'),
+ Cache => '',
},
External => {
HTML5 => FALSE,
@@ -208,7 +209,7 @@ Directory not readable (permission denied): @_r
#
# Strings
- $VERSION = q$Revision: 1.715 $;
+ $VERSION = q$Revision: 1.716 $;
$VERSION =~ s/Revision: ([\d\.]+) /$1/;
#
@@ -322,12 +323,19 @@ if ($lang eq "en") {
$File->{Template_Defaults} = {
die_on_bad_params => FALSE,
- cache => TRUE,
loop_context_vars => TRUE,
global_vars => TRUE,
path => [ catfile($CFG->{Paths}->{Templates}, $lang) ],
filter => sub { my $ref = shift; ${$ref} = Encode::decode_utf8(${$ref}); },
};
+if (IS_MODPERL2()) {
+ $File->{Template_Defaults}->{cache} = TRUE;
+}
+elsif ($CFG->{Paths}->{Cache}) {
+ $File->{Template_Defaults}->{file_cache} = TRUE;
+ $File->{Template_Defaults}->{file_cache_dir} =
+ rel2abs($CFG->{Paths}->{Cache}, tmpdir());
+}
undef $lang;