Dear Monks,

I have a problem with preventing the web clients from caching my scrolling graph and would like to seek your helps. Attached below is a piece of my code. Basically, the code would display a continuous scroll graph. However, the second time I ran the code, the same image is redisplayed on the client screen. If I clicked on refresh, then I would see a new image. I searched the web and the examples I found are similar to this

print "Content-type: image/gif\n\n"; print "Cache-control: no-cache\n"; print "Pragma: no-cache\n"; print "Expires: Mon, 06 May 1996 04:57:00 GMT\n";

However, when I put this into my code, I got an error about incorrect format in my image and nothing is display on the client window. I had to move the

print "Content-type: image/gif\n\n";

below the other three lines to get the error message to go away but then I have a caching problem. Any helps would be appreciated. Thanks.

my @data = ( \@xlabel, \@reads, \@writes, \@updates ); my $graph = GD::Graph::lines->new(400,300); $graph->set( x_label => 'Average Read/Write/Update', y_label => 'Performance ms', title => 'Performance Monitor', y_min_value => 0, y_max_value => $ysp, y_tick_number => 5, y_label_skip => 'auto', x_label_skip => 10, box_axis => 0, ) or die $graph->error; $graph->set_legend( 'Read/Item', 'Write/Item', 'Update/Item'); my $myimage = $graph->plot(\@data); print "Cache-control: no-cache\n"; print "Pragma: no-cache\n"; print "Expires: Mon, 06 May 1996 04:57:00 GMT\n"; print "Content-type: image/gif\n\n"; print $myimage->gif; print "\n"; print "\n--magicalboundarystring\n";

In reply to Preventing Web Client From Caching by Anonymous Monk

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.