Re: stripping CRLF on the way out?

2000-06-24 Thread Ged Haywood

Hi all,

On Thu, 22 Jun 2000, Paul Lindner wrote:

 I read somewhere that 5 bytes is equivalent to 1ms on a 28.8
 connection, so these types of optimizations are generally worth the
 effort.

Don't forget that modems can be clever too.  Most do their own data
compression on the fly, so you may not get the improvement you expect.
If there's less redundancy in the data, there's less to compress away.

73,
Ged.




RE: stripping CRLF on the way out?

2000-06-22 Thread Geoffrey Young

I wrote a quick handler that implements a regex as a PerlHandler

maybe this will help to strip out comments:

(oh, and if anyone would like to see this as an official module, I can clean
it up and release it - I didn't really think there would be much interest in
it when I wrote it...)


package Custom::Regex;

#-
# usage: PerlHandler Custom::Regex
#
#the following variables will be entered into a regex as:
#s/$RegexChange/$RegexTo/eeg
#
#PerlSetVar RegexChange "change this"
#PerlSetVar RegexTo  "to that"
#
#PerlSetVar Filter On   # optional - will work within 
#   # Apache::Filter
#-

use Apache::Constants qw( OK DECLINED SERVER_ERROR );
use Apache::File;
use Apache::Log;
use strict;

$Custom::Regex::VERSION = '0.01';

sub handler {
#-
# initialize request object and variables
#-
  
  my $r = shift;
  my $log   = $r-server-log;

  my $change= $r-dir_config('RegexChange') || undef;
  my $to= $r-dir_config('RegexTo') || undef;

  # make Apache::Filter aware
  my $filter= $r-dir_config('Filter') =~ m/On/i ? 1 : 0;

  my ($fh, $status, $output);  

#-
# do some preliminary stuff...
#-

  $log-info("Using Custom::Regex");

  unless ($r-content_type eq 'text/html') {
$log-info("\trequest is not for an html document - skipping..."); 
$log-info("Exiting Custom::Regex");  
return DECLINED; 
  }

#-
# get the filehandle
#-

  if ($filter) {
$log-info("\tgetting input from Apache::Filter");
($fh, $status) = $r-filter_input;
  } else {
$log-info("\tgetting input from requested Apache::File");
$fh = Apache::File-new($r-filename);
  }

  if (!$fh || $status ne OK) {
$log-warn("\tcannot open request! $!");
$log-info("Exiting Custom::Regex");
return DECLINED;
  }

#-
# do the regex on the request
#-
  
  if ($change  $to) {

$log-info("\tsubstituting $to for $change");

while ($fh) {

  my $output;
  eval { ($output = $_) =~ s/$change/$to/eeg };
  if ($@) {
$log-error("\tsubstitution error: $@");
$log-info("Exiting Custom::Regex");
return SERVER_ERROR;
  } else {
print $output;
  }
}
  }

#-
# wrap up...
#-

  $log-info("Exiting Custom::Regex");

  return OK;
}

1;

--Geoff

 -Original Message-
 From: Dave DeMaagd [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 22, 2000 11:15 AM
 To: [EMAIL PROTECTED]
 Subject: stripping CRLF on the way out?
 
 
 Have an application that generates nicely formatted HTML (from
 templates, so that they can be easily edited), but since there's a
 awful lot of extra line breaks (and other things, like comments) that
 we'd like to strip out (save bandwidth), is there an easy way to do
 this via mod_perl, something like a PerlOutputHandler???  
 
 Something like this would be a far sight easier than having to rewrite
 all of the scripts to do this themselves...  
 
 Any advice would help greatly! 
 
 -- 
 Dave DeMaagd - [EMAIL PROTECTED] - http://www.spinynorm.net
 I don't have a solution, but I admire your problem.
 SysAdmin/Programmer - TheImageGroup - ===|:=P
 



RE: stripping CRLF on the way out?

2000-06-22 Thread Geoffrey Young

I don't use the regex handler all that often, but I thought it might come in
handy for this type of thing.

of course, reducing real-time overhead is always prefered.

HTML::Clean looks like a cool module, I'm sure I'll use it often now that I
know of it - thanks for pointing it out...

--Geoff

 -Original Message-
 From: Paul Lindner [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 22, 2000 10:53 AM
 To: Geoffrey Young
 Cc: 'Dave DeMaagd'; [EMAIL PROTECTED]
 Subject: Re: stripping CRLF on the way out?
 
 
 Try running HTML::Clean on your template, instead of using CPU for
 every request to strip output.
 
 I've done this with some success on a few projects..
 
 Also, Apache::ASP users can activate HTML::Clean to post-process all
 HTML output, which can result in 20-40% savings.
 
 I read somewhere that 5 bytes is equivalent to 1ms on a 28.8
 connection, so these types of optimizations are generally worth the
 effort.
 
   -Original Message-
   From: Dave DeMaagd [mailto:[EMAIL PROTECTED]]
   Sent: Thursday, June 22, 2000 11:15 AM
   To: [EMAIL PROTECTED]
   Subject: stripping CRLF on the way out?
   
   
   Have an application that generates nicely formatted HTML (from
   templates, so that they can be easily edited), but since there's a
   awful lot of extra line breaks (and other things, like 
 comments) that
   we'd like to strip out (save bandwidth), is there an easy 
 way to do
   this via mod_perl, something like a PerlOutputHandler???  
   
   Something like this would be a far sight easier than 
 having to rewrite
   all of the scripts to do this themselves...  
   
   Any advice would help greatly! 
   
   -- 
   Dave DeMaagd - [EMAIL PROTECTED] - http://www.spinynorm.net
   I don't have a solution, but I admire your problem.
   SysAdmin/Programmer - TheImageGroup - ===|:=P
   
 
 -- 
 Paul Lindner
 [EMAIL PROTECTED]
 Red Hat Inc..
 



Re: stripping CRLF on the way out?

2000-06-22 Thread Frank D. Cringle

Dave DeMaagd [EMAIL PROTECTED] writes:
 Have an application that generates nicely formatted HTML (from
 templates, so that they can be easily edited), but since there's a
 awful lot of extra line breaks (and other things, like comments) that
 we'd like to strip out (save bandwidth), is there an easy way to do
 this via mod_perl, something like a PerlOutputHandler???

If you are using templates, why not strip them offline?  I use
HTML::Clean on the my HTML::Templates.  A Makefile keeps the working
version up to date with respect to the source.

-- 
Frank Cringle,  [EMAIL PROTECTED]
voice: (+49 2304) 467101; fax: 943357



stripping CRLF on the way out?

2000-06-22 Thread Dave DeMaagd

Have an application that generates nicely formatted HTML (from
templates, so that they can be easily edited), but since there's a
awful lot of extra line breaks (and other things, like comments) that
we'd like to strip out (save bandwidth), is there an easy way to do
this via mod_perl, something like a PerlOutputHandler???  

Something like this would be a far sight easier than having to rewrite
all of the scripts to do this themselves...  

Any advice would help greatly! 

-- 
Dave DeMaagd - [EMAIL PROTECTED] - http://www.spinynorm.net
I don't have a solution, but I admire your problem.
SysAdmin/Programmer - TheImageGroup - ===|:=P



RE: stripping CRLF on the way out?

2000-06-22 Thread Mark Hewis

If bandwidth is your issue then why not just zip them up look at 

Apache-GzipChain-0.06





-Original Message-
From: Dave DeMaagd [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 22, 2000 4:15 PM
To: [EMAIL PROTECTED]
Subject: stripping CRLF on the way out?


Have an application that generates nicely formatted HTML (from
templates, so that they can be easily edited), but since there's a
awful lot of extra line breaks (and other things, like comments) that
we'd like to strip out (save bandwidth), is there an easy way to do
this via mod_perl, something like a PerlOutputHandler???  

Something like this would be a far sight easier than having to rewrite
all of the scripts to do this themselves...  

Any advice would help greatly! 

-- 
Dave DeMaagd - [EMAIL PROTECTED] - http://www.spinynorm.net
I don't have a solution, but I admire your problem.
SysAdmin/Programmer - TheImageGroup - ===|:=P

This e-mail, and any attachment, is confidential. If you have received it in error, 
please delete it from your system, do not use or disclose the information in any way, 
and notify me immediately. The contents of this message may contain personal views 
which are not the views of the BBC, unless specifically stated.



Re: stripping CRLF on the way out?

2000-06-22 Thread Paul Lindner

Try running HTML::Clean on your template, instead of using CPU for
every request to strip output.

I've done this with some success on a few projects..

Also, Apache::ASP users can activate HTML::Clean to post-process all
HTML output, which can result in 20-40% savings.

I read somewhere that 5 bytes is equivalent to 1ms on a 28.8
connection, so these types of optimizations are generally worth the
effort.

  -Original Message-
  From: Dave DeMaagd [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, June 22, 2000 11:15 AM
  To: [EMAIL PROTECTED]
  Subject: stripping CRLF on the way out?
  
  
  Have an application that generates nicely formatted HTML (from
  templates, so that they can be easily edited), but since there's a
  awful lot of extra line breaks (and other things, like comments) that
  we'd like to strip out (save bandwidth), is there an easy way to do
  this via mod_perl, something like a PerlOutputHandler???  
  
  Something like this would be a far sight easier than having to rewrite
  all of the scripts to do this themselves...  
  
  Any advice would help greatly! 
  
  -- 
  Dave DeMaagd - [EMAIL PROTECTED] - http://www.spinynorm.net
  I don't have a solution, but I admire your problem.
  SysAdmin/Programmer - TheImageGroup - ===|:=P
  

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.