[Jifty-commit] r1656 - in jifty/trunk:
share/web/templates/__jifty/css share/web/templates/__jifty/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Jul 24 12:38:23 EDT 2006
Author: trs
Date: Mon Jul 24 12:38:19 2006
New Revision: 1656
Modified:
jifty/trunk/ (props changed)
jifty/trunk/share/web/templates/__jifty/css/dhandler
jifty/trunk/share/web/templates/__jifty/js/dhandler
Log:
r14730 at zot: tom | 2006-07-24 12:33:48 -0400
Gzip compress the squished CSS and JS if possible. The static handler usually deals with this, but we're not serving squished CSS/JS from the static root.
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 Mon Jul 24 12:38:19 2006
@@ -20,6 +20,20 @@
$r->content_type("text/css");
$r->header_out( 'Expires' => HTTP::Date::time2str(time + 31536000) );
-Jifty->web->out( Jifty->web->cached_css );
+# 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
+# for us.
+use Compress::Zlib qw();
+
+if ( Jifty::View::Static::Handler->client_accepts_gzipped_content ) {
+ Jifty->log->debug("Sending gzipped squished CSS");
+ $r->header_out( "Content-Encoding" => "gzip" );
+ binmode STDOUT;
+ print Compress::Zlib::memGzip( Jifty->web->cached_css );
+}
+else {
+ Jifty->log->debug("Sending squished CSS");
+ print Jifty->web->cached_css;
+}
return;
</%init>
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 Mon Jul 24 12:38:19 2006
@@ -20,6 +20,20 @@
$r->content_type("application/x-javascript");
$r->header_out( 'Expires' => HTTP::Date::time2str(time + 31536000) );
-Jifty->web->out( Jifty->web->cached_javascript );
+# 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
+# for us.
+use Compress::Zlib qw();
+
+if ( Jifty::View::Static::Handler->client_accepts_gzipped_content ) {
+ Jifty->log->debug("Sending gzipped squished JS");
+ $r->header_out( "Content-Encoding" => "gzip" );
+ binmode STDOUT;
+ print Compress::Zlib::memGzip( Jifty->web->cached_javascript );
+}
+else {
+ Jifty->log->debug("Sending squished JS");
+ print Jifty->web->cached_javascript;
+}
return;
</%init>
More information about the Jifty-commit
mailing list