Without seeing the program, I can see two possible causes:

  1. Your program is reading (what it thinks is) the new data from the old file through an open file handle to the old file. If you keep a file handle open to a file, some operating systems allow you to unlink or rename the file to a new name and still read the data from it through the filehandle. This is only testable by inspecting your program and looking at the control flow. I recommend ripping out all CGI-related functionality and first making sure that the program works correctly from the command line, updating the file and displaying the correct data set.
  2. Your browser caches the data and displays the old data. This should be easily verified by reloading the page from the browser.
  3. You're using some data caching and a persistent environment like mod_perl. Then you have to update or invalidate your cache as well as updating the file on disk.

A technique which I use fairly often to separate changing the data from displaying the data is to modify the data in one request and then send a Location: http://... redirect header to the page that then displays the (now changed) data. This allows me to nicely separate the two operations, at the cost of an additional HTTP request for every modification.


In reply to Re: Caching problem? by Corion
in thread Caching problem? by viffer

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.