in reply to Automatic page refresh

Since you're using CGI, when you print out the CGI headers from your script add:
-expires => 'now'
For example:
print(header(-expires => 'now'));
This directive is supposed to cause the browser to expire the page in its cache and get a fresh copy the next time the page is displayed.

Remember: There's always one more bug.

Replies are listed 'Best First'.
Re^2: Automatic page refresh
by dorward (Curate) on Jul 28, 2005 at 12:57 UTC

    You shouldn't set the expires header to be "now" (update (thanks frodo72): but that code doesn't set the header to be "now", it is converted to an actual date. That's teach me to not test - you only ever get something wrong if you don't test, 99% of the time, if you do test, your test will give the expected result). The spec says that it must be in HTTP-Date format. It does also say that if a client recieves anything that isn't HTTP-Date, then it should treat it as "already expired" - but intentionally triggering error recovery isn't a fantastic idea.

    Other caching headers might also come in useful. Caching Tutorial for Web Authors and Webmasters is a worthwhile read.

      But the respondent is suggesting to set the -expire parameter of the header function to now, which is pretty different. From CGI docs:
      Most browsers will not cache the output from CGI scripts. Every time the browser reloads the page, the script is invoked anew. You can change this behavior with the -expires parameter. When you specify an absolute or relative expiration interval with this parameter, some browsers and proxy servers will cache the script's output until the indicated expiration date. The following forms are all valid for the -expires field:
      +30s 30 seconds from now +10m ten minutes from now +1h one hour from now -1d yesterday (i.e. "ASAP!") now immediately +3M in three months +10y in ten years time Thursday, 25-Apr-1999 00:40:33 GMT at the indicated time & da +te

      Flavio
      perl -ple'$_=reverse' <<<ti.xittelop@oivalf

      Don't fool yourself.
Re^2: Automatic page refresh
by Anonymous Monk on Jul 28, 2005 at 12:50 UTC
    Thanks, folks

    This works a treat!

    C J