[Jifty-commit] r2796 - in jifty/trunk: lib/Jifty
share/web/templates/__jifty/css
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Feb 16 08:04:39 EST 2007
Author: dpavlin
Date: Fri Feb 16 08:04:37 2007
New Revision: 2796
Modified:
jifty/trunk/lib/Jifty/Web.pm
jifty/trunk/share/web/templates/__jifty/css/dhandler
jifty/trunk/share/web/templates/__jifty/js/dhandler
Log:
send correct HTTP/1.1 headers for caching when running Jifty with DevelMode: 0
Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm (original)
+++ jifty/trunk/lib/Jifty/Web.pm Fri Feb 16 08:04:37 2007
@@ -26,8 +26,8 @@
);
__PACKAGE__->mk_classdata($_)
- for qw(cached_css cached_css_digest
- cached_javascript cached_javascript_digest javascript_libs);
+ for qw(cached_css cached_css_digest cached_css_time
+ cached_javascript cached_javascript_digest cached_javascript_time javascript_libs);
__PACKAGE__->javascript_libs([qw(
jsan/JSAN.js
@@ -1011,6 +1011,7 @@
__PACKAGE__->cached_css( $css );
__PACKAGE__->cached_css_digest( md5_hex( $css ) );
+ __PACKAGE__->cached_css_time( time );
}
}
@@ -1132,6 +1133,7 @@
__PACKAGE__->cached_javascript( $js );
__PACKAGE__->cached_javascript_digest( md5_hex( $js ) );
+ __PACKAGE__->cached_javascript_time( time );
}
}
Modified: jifty/trunk/share/web/templates/__jifty/css/dhandler
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/css/dhandler (original)
+++ jifty/trunk/share/web/templates/__jifty/css/dhandler Fri Feb 16 08:04:37 2007
@@ -9,7 +9,7 @@
use HTTP::Date ();
-if ( Jifty->handler->cgi->http('If-Modified-Since')
+if ( ( Jifty->handler->cgi->http('If-Modified-Since') or Jifty->handler->cgi->http('If-None-Match') )
and $m->dhandler_arg eq Jifty->web->cached_css_digest . '.css' )
{
Jifty->log->debug("Returning 304 for cached css");
@@ -19,6 +19,9 @@
$r->content_type("text/css");
$r->header_out( 'Expires' => HTTP::Date::time2str(time + 31536000) );
+$r->header_out( 'Last-Modified' => HTTP::Date::time2str( Jifty->web->cached_css_time ) );
+$r->header_out( 'Age' => time - Jifty->web->cached_css_time );
+$r->header_out( 'Etag' => Jifty->web->cached_css_digest );
# XXX TODO: If we start caching the squished CSS in a file somewhere, we
# can have the static handler serve it, which would take care of gzipping
Modified: jifty/trunk/share/web/templates/__jifty/js/dhandler
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/js/dhandler (original)
+++ jifty/trunk/share/web/templates/__jifty/js/dhandler Fri Feb 16 08:04:37 2007
@@ -9,7 +9,7 @@
use HTTP::Date ();
-if ( Jifty->handler->cgi->http('If-Modified-Since')
+if ( ( Jifty->handler->cgi->http('If-Modified-Since') or Jifty->handler->cgi->http('If-None-Match') )
and $m->dhandler_arg eq Jifty->web->cached_javascript_digest . '.js' )
{
Jifty->log->debug("Returning 304 for cached javascript");
@@ -19,6 +19,9 @@
$r->content_type("application/x-javascript");
$r->header_out( 'Expires' => HTTP::Date::time2str(time + 31536000) );
+$r->header_out( 'Last-Modified' => HTTP::Date::time2str( Jifty->web->cached_javascript_time ) );
+$r->header_out( 'Age' => time - Jifty->web->cached_javascript_time );
+$r->header_out( 'Etag' => Jifty->web->cached_javascript_digest );
# XXX TODO: If we start caching the squished JS in a file somewhere, we
# can have the static handler serve it, which would take care of gzipping
More information about the Jifty-commit
mailing list