[Rt-commit] rt branch, 4.0/helpers-http-cache-headers, updated. rt-4.0.8-307-g529800c

Todd Wade todd at bestpractical.com
Fri Apr 5 12:12:39 EDT 2013


The branch, 4.0/helpers-http-cache-headers has been updated
       via  529800c2c90f0c6cc76b8a73416c1874d1d925cb (commit)
      from  27bd738eafa5367e6013836210e8a4a7d4244d71 (commit)

Summary of changes:
 lib/RT/Interface/Web.pm            |  6 +-----
 t/web/helpers-http-cache-headers.t | 13 +++++++++++--
 2 files changed, 12 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit 529800c2c90f0c6cc76b8a73416c1874d1d925cb
Author: Todd Wade <todd at bestpractical.com>
Date:   Fri Apr 5 12:12:00 2013 -0400

    refactor StaticFileHeaders to use CacheControlExpiresHeaders + test

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 8831ad0..e9b4df0 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -915,16 +915,12 @@ This routine could really use _accurate_ heuristics. (XXX TODO)
 sub StaticFileHeaders {
     my $date = RT::Date->new(RT->SystemUser);
 
-    # make cache public
-    $HTML::Mason::Commands::r->headers_out->{'Cache-Control'} = 'max-age=259200, public';
-
     # remove any cookie headers -- if it is cached publicly, it
     # shouldn't include anyone's cookie!
     delete $HTML::Mason::Commands::r->err_headers_out->{'Set-Cookie'};
 
     # Expire things in a month.
-    $date->Set( Value => time + 30 * 24 * 60 * 60 );
-    $HTML::Mason::Commands::r->headers_out->{'Expires'} = $date->RFC2616;
+    CacheControlExpiresHeaders( Time => 'forever' );
 
     # if we set 'Last-Modified' then browser request a comp using 'If-Modified-Since'
     # request, but we don't handle it and generate full reply again
diff --git a/t/web/helpers-http-cache-headers.t b/t/web/helpers-http-cache-headers.t
index 48371a2..d4d201d 100644
--- a/t/web/helpers-http-cache-headers.t
+++ b/t/web/helpers-http-cache-headers.t
@@ -24,7 +24,7 @@ ok $m->login, 'logged in';
 my $docroot = join '/', qw(share html);
 
 # find endpoints to loop over
-my @endpoints;
+my @endpoints = ('/NoAuth/css/print.css');
 find({
   wanted => sub {
     if ( -f $_ && $_ !~ m|autohandler$| ) {
@@ -59,6 +59,10 @@ diag "set up expected date headers";
       'Cache-Control' => 'max-age=120, private',
       'Expires'       => 'Fri, 5 Apr 2013 15:30:19 GMT',
     },
+    NoAuth      => {
+      'Cache-Control' => 'max-age=2592000, public',
+      'Expires'       => 'Sun, 5 May 2013 15:28:19 GMT',
+    },
     default      => {
       'Cache-Control' => 'no-cache',
       'Expires'       => 'Fri, 5 Apr 2013 15:28:19 GMT',
@@ -70,7 +74,12 @@ diag "set up expected date headers";
 foreach my $endpoint ( @endpoints ) {
   $m->get_ok( $endpoint . "?id=${ticket_id}&Status=open&Requestor=root" );
 
-  my $header_key = $endpoint =~ m|Autocomplete| ? 'Autocomplete' : 'default';
+  my $header_key = 'default';
+  if ( $endpoint =~ m|Autocomplete| ) {
+    $header_key =  'Autocomplete';
+  } elsif ( $endpoint =~ m|NoAuth| ) {
+    $header_key =  'NoAuth';
+  }
   my $headers = $expected->{$header_key};
 
   is(

-----------------------------------------------------------------------


More information about the Rt-commit mailing list