I thought it would be a good idea to cache it to a text file and use that if it under a few hours old.

It certainly would be a good idea. However, if you'll permit me to chip in with the results of my experience, I caution against writing such a caching system yourself. I have done this more than once and have also inherited code where others have done this more than once. In every single case the caching system has drawbacks - one or two are serious, all are irritating.

In Perl we are fortunate indeed to have a very high-quality but generic and flexible cache module available to use in the shape of CHI and it would be hard to praise it too highly. Do try it out in your (apparently fairly simple) use case. You should find it easy to use and very efficient and hopefully that will encourage you to use it for other, more involved, cache scenarios.

Is there a standard way to handle this?

To quote AST: The nice thing about standards is that you have so many of them to choose from.


🦛


In reply to Re: Where to save module data by hippo
in thread Where to save module data by Bod

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.