perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Per Einar Ellefsen <>
Subject Re: Graphics and mod_perl
Date Thu, 03 Oct 2002 05:28:49 GMT
At 01:41 03.10.2002, Justin Luster wrote:

>I m new to mod_perl and I m really enjoying it.  It has really improved 
>performance.  Right now I m just using Modperl::Registry to speed up 
>things.  I have a question about showing graphics using a Perl Script and 
>running it through mod_perl.
>Using Perl under regular CGI to create a dynamic web page I have always used:
>print <img src=\ thefile.jpg\ > ;
>and this would display the graphic to the web page assuming that the file 
>thefile.jpg  was in the same directory as the Perl script .  If the 
>graphic was in another directory then something like:
>print <img src=\ ../graphics/thefile.jpg\ > ;
>print <img src=\\ > ;
>but it seems that there is a delay in displaying the graphic when I do this.
>Where is the current working directory when running a Perl script under 

Hello Justin,

You seem to misunderstand the working of the HTML <img> tag. All you're 
doing is to give an idea to the *browser* about where it should find the 
image, relatively to the *URI* of your script.
Simply put, before you had:
/cgi-bin/yourscript.cgi ---> img src="thefile.jpg" ---> browser tries to 
fetch /cgi-bin/thefile.jpg
Now, you have:
/ssiweb/ ----> img src="../graphics/thefile.jpg" ---> browser 
fetches /ssiweb/../graphics/thefile.jpg = /graphics/thefile.jpg

You have almost found the best solution when in doubt: using absolute URIs.
However, as you noticed, using the full URL is slower because the browser 
has to check the DNS again etc etc.
So, if your graphics are acccessible as, then you can insert an img tag 
with src="/graphics/file.jpg". Note the first slash which says to the 
browser "Begin at the root of this site and fetch the following URI".


Per Einar Ellefsen

View raw message