campbell has asked for the wisdom of the Perl Monks concerning the following question:
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 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:
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.#!/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;
Any ideas as to what's going on?
Thanks in advance,
Campbell
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Web server cache-ing?
by almut (Canon) on May 22, 2008 at 12:37 UTC | |
by CountZero (Bishop) on May 22, 2008 at 14:31 UTC | |
by campbell (Beadle) on May 22, 2008 at 13:38 UTC | |
by almut (Canon) on May 22, 2008 at 13:49 UTC | |
by Anonymous Monk on May 22, 2008 at 14:27 UTC | |
|
Re: Web server cache-ing?
by moritz (Cardinal) on May 22, 2008 at 13:06 UTC | |
|
Re: Web server cache-ing?
by Anonymous Monk on May 22, 2008 at 12:26 UTC |