books
Free Books / Computers / Practical mod_perl /

previous page: 13.8. time( ) System Call Versus $r->request_time
  
page up: Practical mod_perl | by Stas Bekman and Eric Cholet
  
next page: 13.10. Caching and Pre-Caching

13.9. Printing Unmodified Files




Description

This section is from the "Practical mod_perl" book, by Stas Bekman and Eric Cholet. Also available from Amazon: Practical mod_perl

To send a complete file from disk, without applying any modifications first, instead of:

my $filename = "/tmp/foo";
my $fh = Apache::gensym( );  # generate a new filehandle
open $fh, $filename or return NOT_FOUND;
print <$fh>;
close $fh;

it's better to write:

my $filename = "/tmp/foo";
my $fh = Apache::gensym( );  # generate a new filehandle
open $fh, $filename or return NOT_FOUND;
$r->send_fd($fh);
close $fh;

The former implementation uses more memory and it's slower, because it creates a temporary variable to read the data in and then print it out. The latter uses optimized C code to read the file and send it to the client.

 

Continue to:

  • prev: 13.8. time( ) System Call Versus $r->request_time
  • Table of Contents
  • next: 13.10. Caching and Pre-Caching

Books by Stas Bekman:















TOP
previous page: 13.8. time( ) System Call Versus $r-&gt;request_time
  
page up: Practical mod_perl | by Stas Bekman and Eric Cholet
  
next page: 13.10. Caching and Pre-Caching

Topics

  • Animals
  • Architecture
  • Arts
  • Business
  • Computers
  • Crafts
  • Fairy Tales
  • Finance
  • Flora and Plants
  • Cooking
  • Gardening
  • Health and Healing
  • History
  • Home Improvements
  • Languages
  • New Age
  • Novels
  • Real Estate
  • Reference
  • Religion
  • Science
  • Society
  • Sports
  • Travel
  • Outdoors


Search

My Books

Headaches Begone! A Systemic Approach To Healing Your Headaches
Don't Let Your Bike Seat Ruin Your Sex Life Book

Discover

  • Answers FAQ

[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007-2021 StasoSphere.com