Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I've a CGI script that was recently changed to fixed a bug. I then uploaded the script to the server. However, for one online user, the bug appears to be still there. I'm wondering if it's because the particular user's browser has some kind of feature that caches CGI behaviour, espeically when the script's filename is not changed. Does anyone have similar experiences?

Would appreciate any help :)

Replies are listed 'Best First'.
Re: [OT] CGI script cached by browser?
by jhourcle (Prior) on Apr 14, 2006 at 14:58 UTC

    Normal cause of that problem -- the CGI exists in more than one location, and you only updated one copy. The 'problem' user is looking at the other copy.

    CGIs should only be cached if they're using GET -- POST is considered an 'unsafe' operation, which must be reapplied, but it's possible that a proxy might cache the results from a GET request, and it really can't tell the different between a CGI and a static page. (it can guess, but it's only a guess)

    Depending on how much traffic you get, I'd probably either just tail the access log, grepping for the user's IP address, and see if they make contact with your machine (and what the file is they're asking for). If they don't, I'd check their proxy settings, and see if they're routing their traffic through some other host.

    After that, you start getting into the trickier situations -- do they have your server overridden in their /etc/hosts or the equivalent (yes, it seems strange, but I've been known to have some machines send all requests for the production server to the development server, so I don't have to worry about absolute URLs). Is DNS working for the user? Are the using the correct DNS server? (seems like a stupid question -- until we found that somehow AOL had found a development DNS server that the admin hadn't put on a closed subnet ... lost ~2 weeks of my time on that one)

    Is there anything else different about the user? Different browser? different browser version? different OS? something? Find out what that is, and you might have some insight into the problem.

    Oh ... and if you're concerned about caching ... look into cache control headers.

    Update: this is a really stupid thing, but I just remembered -- back in 1994?5? or so (back in the days of Netscape 0.9), we had some massive issues when daylight savings first rolled around -- caching got all messed up, as the browser was sending the wrong timestamp to the server, and the server would respond with 304. I would hope there aren't any browsers/servers/proxies that still have this problem, but when it happens, it's really annoying. If the user's stuff suddenly works after the change has been in for an hour, it's something to look at.

Re: [OT] CGI script cached by browser?
by sgifford (Prior) on Apr 14, 2006 at 16:39 UTC
    Browsers won't cache a CGI script, but they may cache its output. You can control this somewhat with headers like Cache-control and Expires, but not after the fact.

    If it is in fact a problem with a cached page generated by a CGI script, the user should be able to fix the problem by clearing their cache, quitting their browser, then re-visiting the page; or by force-reloading the page in their browser (Shift-Reload in Mozilla/Firefox/Netscape, either Ctrl- or Shift-F5 in IE).

Re: [OT] CGI script cached by browser?
by ikegami (Patriarch) on Apr 14, 2006 at 21:38 UTC
    Check your web logs. If the user is not shown to request the CGI, it's because his browser or proxy is caching an earlier result. Otherwise, you may still have a problem with your script.
Re: [OT] CGI script cached by browser?
by Anonymous Monk on Apr 15, 2006 at 02:29 UTC

    Thanks to all :)

    I thought it might be something to do with the browser caching the script. But as pointed out by sgifford, the browser only caches the result.

    So it's probably the script. I did more testing but couldn't nail down the bug. Basically it's to do with the value of a variable that is inserted or updated into the database. This value should not exceed a certain upper bound. But for this user, it had exceeded that maximum value.

    My tentative solution is to alert me with an email when the upper bound is exceeded and to re-adjust it for the user before it's added to the database.