Permalink
Browse files

disable caching by default, to ease installation

  • Loading branch information...
1 parent be65eff commit 3eb1d5650c9a7896d332fbbe3499fe755bec503c @moritz committed Sep 20, 2011
Showing with 38 additions and 28 deletions.
  1. +4 −6 README
  2. +1 −0 cgi/cgi.conf
  3. +15 −10 cgi/channel-index.pl
  4. +15 −11 cgi/index.pl
  5. +3 −1 cgi/out.pl
View
10 README
@@ -4,9 +4,7 @@ The documentation can be found at http://moritz.faui2k3.org/en/ilbot
Installation instructs are still sorely missing, sorry about that.
-Note that pages are cached for performance reason; after you change
-anything significant, remove the file cache:
-
- rm -rf /tmp/FileCache/irclog/
-
-Before reloading the page in your browser.
+Note that in production mode, pages are cached for performance reason.
+During the installation, you should have caching disabled (by
+setting NO_CACHE = 1 in cgi.conf). Once you're confident with your setup,
+remove that setting again.
View
@@ -1 +1,2 @@
BASE_URL = /
+NO_CACHE = 1
View
@@ -10,24 +10,30 @@
use lib 'lib';
use IrcLog qw(get_dbh gmt_today);
+my $conf = Config::File::read_config_file('cgi.conf');
+
# test_calendar();
go();
sub go {
- my $q = new CGI;
+ my $q = CGI->new;
my $channel = $q->url_param('channel');
print "Content-Type: text/html; charset=utf-8\n\n";
- my $cache_name = $channel . '|' . gmt_today();
- my $cache = new Cache::FileCache({ namespace => 'irclog' });
- my $data = $cache->get($cache_name);
+ if ($conf->{NO_CACHE}) {
+ print get_channel_index($channel);
+ } else {
+ my $cache_name = $channel . '|' . gmt_today();
+ my $cache = new Cache::FileCache({ namespace => 'irclog' });
+ my $data = $cache->get($cache_name);
- if (! defined $data) {
- $data = get_channel_index($channel);
- $cache->set($data, '2 hours');
- }
+ if (! defined $data) {
+ $data = get_channel_index($channel);
+ $cache->set($data, '2 hours');
+ }
- print $data;
+ print $data;
+ }
}
sub test_calendar {
@@ -41,7 +47,6 @@ sub test_calendar {
sub get_channel_index {
my $channel = shift;
- my $conf = Config::File::read_config_file('cgi.conf');
my $base_url = $conf->{BASE_URL} || q{/};
my $t = HTML::Template->new(
View
@@ -11,23 +11,27 @@
use Cache::FileCache;
print http_header();
-my $cache = new Cache::FileCache( {
- namespace => 'irclog',
- } );
-
-my $data;
-$data = $cache->get('index');
-if ( ! defined $data){
- $data = get_index();
- $cache->set('index', $data, '5 hours');
+my $conf = Config::File::read_config_file('cgi.conf');
+
+if ($conf->{NO_CACHE}) {
+ print get_index();
+} else {
+ my $cache = new Cache::FileCache( {
+ namespace => 'irclog',
+ } );
+
+ my $data = $cache->get('index');
+ if ( ! defined $data){
+ $data = get_index();
+ $cache->set('index', $data, '5 hours');
+ }
+ print $data;
}
-print $data;
sub get_index {
my $dbh = get_dbh();
- my $conf = Config::File::read_config_file('cgi.conf');
my $base_url = $conf->{BASE_URL} || q{/irclog/};
my $sth = $dbh->prepare("SELECT DISTINCT channel FROM irclog");
View
@@ -100,7 +100,9 @@
}
-{
+if ($conf->{NO_CACHE}) {
+ print irclog_output($date, $channel);
+} else {
my $cache_key = $channel . '|' . $date . '|' . $count;
# the current date is different from all other pages,
# because it doesn't have a 'next day' link, so make

0 comments on commit 3eb1d56

Please sign in to comment.