[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] Disabling caching of output?



Hi all:

I have this script that outputs copyrighted hi-res images from my site only
after the user has registered, etc.
For the final stage, I have a form from where you can choose the image to
download. This form accesses "download.cgi" with the id number of the images
to output.

The problem is that once you have downloaded one image and choose another
one, the browser displays the first outputted image from its cache instead
of waiting for the script to send the new one. I've tried to disable caching
of the outputted image by means of http headers, but it's just not working.

I'm enclosing the code of the sub that does the actual outputting.
Any suggestions would be greatly appreciated.

 
-----snippet----

sub display_img {
    my $img = shift;
    my $buffer = '';
    my $buffer_size = 4_096;  # Is this a good buffer size?
    
    open (IMAGE, "$img");
    print $q->header( -type => 'image/jpeg',
                                    -expires => '-1d',
                                    'Pragma: no-cache');  ## Using CGI !
    binmode STDOUT;
    while ( read(IMAGE, $buffer, $buffer_size) ) {
        print $buffer;
        }
    close (IMAGE);
}

--
mailto:perotti@pobox.com
http://riccardoperotti.com



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org