Howdy fellow monks,

This is the basic outline of what I am trying to accomplish:

  1. Get most recent data from DB
  2. Add data to Excel Spreadsheet
  3. That data updates a chart in Excel
  4. Export chart to .gif file
  5. Display .gif file with some wrapping text in CGI

I have the first four parts working, but I am struggling with how to design the last one for good performance in a CGI environment.

There are two considerations. First, I need to ensure that the file-names don't get clobbered. Second, I would like to ensure that if a .gif has been created recently (say within 48 hours) it doesn't get recreated. This latter part is needed because the Excel-portion (especially the actually export) takes several seconds, so the server could get really bogged down on this.

The approach that comes to mind is to name the files according to a primary key from the database (well, the data is from multiple tables, but I can just concatenate the various keys together). I would then check the file-date, and if it is less than n-hours old, just display, otherwise unlink and make a new one.

Is that a sound approach? Are there other hidden gotchas in this kind of thing? Any/all advice/suggestions welcome!

-Tats

In reply to Strategies for temporary image files in CGI by Itatsumaki

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.