Add X-Forever
authorMarius Gavrilescu <marius@ieval.ro>
Thu, 6 Feb 2014 10:46:59 +0000 (12:46 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Thu, 6 Feb 2014 10:46:59 +0000 (12:46 +0200)
lib/Gruntmaster/Page/Base.pm
lib/Gruntmaster/Page/CSS.pm
lib/Gruntmaster/Page/JS.pm
lib/Gruntmaster/Page/Register.pm
lib/Gruntmaster/Page/Src.pm

index bc8e9cec1b176e81c63a37cb903cbf880fdd6206..0585985cc9bd09bf0462e87239bc8f17b6e730c9 100644 (file)
@@ -13,6 +13,9 @@ use HTML::Template::Compiled;
 use POSIX ();
 use Gruntmaster::Data ();
 use List::Util ();
+use LWP::UserAgent;
+
+my $ua = LWP::UserAgent->new;
 
 sub import {
        my $caller = caller;
@@ -29,8 +32,12 @@ sub import {
                local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1;
                $_[0]->{'psgix.logger'}->({qw/level debug message/ => $_[1]})
        };
-       *{"${caller}::reply"} = sub { [200, ['Content-Type' => 'text/plain'], [ @_ ] ] }
-
+       *{"${caller}::reply"} = sub { [200, ['Content-Type' => 'text/plain'], [ @_ ] ] };
+       *{"${caller}::purge"} = sub {
+               return unless $ENV{PURGE_HOST};
+               my $req = HTTP::Request->new(PURGE => "http://$ENV{PURGE_HOST}$_[0]");
+               $ua->request($req)
+       };
 }
 
 ##################################################
@@ -139,7 +146,7 @@ sub generate{
 
        my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$self}{$lang}, default_escape => 'HTML',);
        $self->_generate($htc, $lang, @args);
-       [200, ['Content-Type' => 'text/html', 'Content-Language' => $_[1], 'Vary' => 'Accept-Language'], [ encode 'UTF-8' => $htc->output ] ]
+       [200, ['Content-Type' => 'text/html', 'Content-Language' => $_[1], 'Vary' => 'Accept-Language', 'X-Forever' => 1], [ encode 'UTF-8' => $htc->output ] ]
 }
 
 sub _generate {}
index 25b613777acc737b295d544bdbe7b0452ef2cec3..2553ab6e5c0833f9371850f83a39d59031b5f65c 100644 (file)
@@ -16,7 +16,7 @@ sub generate{
        return [404, ['Content-Type' => 'text/plain'], [ 'Not found' ]] unless -e "css/themes/$theme.css";
        my $css = read_file "css/themes/$theme.css";
        $css .= read_file $_ for <css/*.css>;
-       [200, ['Content-Type' => 'text/css', 'Cache-Control' => 'public, max-age=604800'], [minify $css] ]
+       [200, ['Content-Type' => 'text/css', 'Cache-Control' => 'public, max-age=604800', 'X-Forever' => 1], [minify $css] ]
 }
 
 sub variants{ [[css => 1, 'text/css', undef, undef, undef, undef]] }
index dca5affe76e7ab247dbbfa0bdf40573d86d33b47..9e78192d0b12575b9107cf57f3207330da93c19b 100644 (file)
@@ -15,7 +15,7 @@ sub generate{
        debug $env => "";
        my $js;
        $js .= read_file $_ for <js/*.js>;
-       [200, ['Content-Type' => 'application/javascript', 'Cache-Control' => 'public, max-age=604800'], [$js] ]
+       [200, ['Content-Type' => 'application/javascript', 'Cache-Control' => 'public, max-age=604800', 'X-Forever' => 1], [$js] ]
 }
 
 sub variants{ [[js => 1, 'application/javascript', undef, undef, undef, undef]] }
index 4b93a849802793ae25e252357d95534bb9434028..dcb9451ebd8c40b682372e728796a047fb58c9e0 100644 (file)
@@ -23,8 +23,7 @@ sub generate{
 
        insert_user $username, name => $name, email => $email, phone => $phone, town => $town, university => $university, level => $level;
 
-       #PUBLISH genpage =>  "us/index.html";
-       #PUBLISH genpage =>  "us/$username.html";
+       purge  "/us/";
        reply 'Registered successfully';
 }
 
index b7b94332b3ec0a18a9343dae0300e5192d9b1606..8e51d8ba71b676455badcb638a57a5ee1d7f6407 100644 (file)
@@ -22,7 +22,7 @@ sub generate{
        debug $env => "Contest is $ct, job is $job and extension is $ext";
        local $Gruntmaster::Data::contest = $ct if $ct;
 
-       [200, ['Content-Type' => CONTENT_TYPES->{$ext}, 'Cache-Control' => 'max-age=604800'], [job_inmeta($job)->{files}{prog}{content}] ]
+       [200, ['Content-Type' => CONTENT_TYPES->{$ext}, 'Cache-Control' => 'max-age=604800', 'X-Forever' => 1], [job_inmeta($job)->{files}{prog}{content}] ]
 }
 
 sub variants{ [[file => 1, undef, undef, undef, undef, undef]] }
This page took 0.014128 seconds and 4 git commands to generate.