Greetings

This is a follow-up to a previous problem I posted in SOPW (see Use of GD::Graph).

Having successfully implemented the solution proposed to me (i.e. printing images to file, and then calling them back from file using <img> tags), I am now finding that the images, rather than being updated when I click the submit button in my form, are only being updated when I hit the refresh button in my browser. I suspected this was something to do a web-server or proxy cache-ing the web page somewhere along the line, so I put the following line in my code to print to the HTTP header :

print "Cache-Control: no-cache\n";

My local webmaster also tells me that the web-server is not doing any cacheing. However, inserting this line did not solve the problem and I suspect that there is something erroneous going on with writing to and retrieving from the files.

Here are the relevant parts of my code:

#!/usr/bin/perl -w use strict; use warnings; use CGI qw/:standard *table *Tr *td/; use CGI::Carp qw(fatalsToBrowser); use Date::Manip; use DBI; use GD::Graph; use GD::Graph::bars; use GD::Graph::lines; use GD::Graph::linespoints; my $image_directory="/var/www/html/foo/bar/"; my $image_web_path="http://(IPaddress here)/foo/bar/"; print "Cache-Control: no-cache\n"; print header; print start_html( -title=>'Online search', -style=>'(link to style sheet)' ); my @imagefiles; for (my $i=1; $i<=8; $i++){$imagefiles[$i]=$image_directory.'imagefile +'.$i.'.gif';} ... (form to acquire parameters specifying beginning and ending of search +period) ... (database interrogation based on above search period, writing data to +various data structures, then preparing the data to be processed by G +D::Graph) ... #Output the results of the database interrogation as a graph using GD +::Graph and write it to file like so: open IMAGEFILE, ">$imagefiles[6]" or die "Couldn't open $imagefile +s[6]:$!"; binmode STDOUT; my $gd3_lines_average=$linegraph3_average->plot(\@linedata3_averag +e)->$format3_lines_average() or die $linegraph3_average->error; print IMAGEFILE $gd3_lines_average; close IMAGEFILE; ... Create the other image files in a similar way to the one above ... print img({-src=>$image_web_path.'imagefile6.gif',-width=>"400",-heigh +t=>"300",-alt=>"No of foos in month bar"}) ... Retrieve the other image files in a similar way to the one above ... print end_html;
I've also tried retrieving the images as local files but to no avail. I could implement the second solution that was proposed to me, i.e. passing the form parameters to a second Perl script that output the images on the fly, but having gone down this route I would like to at least have a go at solving this problem before I do so.

Any ideas as to what's going on?

Thanks in advance,
Campbell


In reply to Web server cache-ing? by campbell

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.