Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm writing a modperl application (running under Apache::Registry) where i decided to serve images from the DB for various reasons. I got a simple CGI script to serve images, it looks like this:
use strict; use lib '/path/to/my/lib/'; use MyDBI; #export $dbh use CGI qw(header path_info); my ($id, $image) = path_info() =~ m{(\d+)_((?:image|thumb|mini)[1-3])(_.+)?\.jpe?g$} +i; exit unless $id and $image; my ($file) = $dbh->selectrow_array("SELECT $image from offerte WHERE +id=$id"); exit unless $file; print header(-type => 'image/jpeg', -Content_length => length $file), +$file;
This is working fine except for caching. Browsers keeps on asking conditional GETs sending If-Modified-Since fields.
As the filenames changes if the image changes all i want to do is just replying a 304 header if i receive a conditional GET.
Can i do it with a simple script like mine, do i have to use Apache API or do i have to install an Apache handler?


$|=$_="1g2i1u1l2i4e2n0k",map{print"\7",chop;select$,,$,,$,,$_/7}m{..}g


In reply to Caching images from RDBMS by giulienk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2024-04-19 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found