Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Why does back-buttoning to a cgi script-output page yield 'Page expired'?

by dyfn (Initiate)
on Feb 14, 2000 at 00:04 UTC ( #3436=categorized question: print w/replies, xml ) Need Help??
Contributed by dyfn on Feb 14, 2000 at 00:04 UTC
Q&A  > CGI programming


Script invoked with post method:
<FORM METHOD="POST" ACTION="http://url/cgi-bin/search_engine.cgi"> wit +h <INPUT TYPE="text" SIZE="30" NAME="keywords" MAXLENGTH="80">
Returns page of site urls.

Answer: Why does back-buttoning to a CGI page yield 'Page expired'?
contributed by Anonymous Monk

This is probably a feature:

Where I have CGI-generated pages I often set an expiry date of 'now' to force the browser to reload each time the page is accessed. I want to avoid the cache giving out-of-date info. On Netscape I notice that this gives a 'Page expired' error on back-button (which is better than using old page!).

Could be you've got something similar?

Answer: Why does back-buttoning to a cgi script-output page yield 'Page expired'?
contributed by Russ

This is really a feature, though many users find it an annoyance. In the HTTP standard, the intent is to limit network traffic transferring files that have not changed. So, if your browser has already received a file, it will not fetch it over and over again (unless you have set it do so).

Dynamically created content — like the output of cgi scripts — needs an expiration to let your browser know how long it will be valid. Imagine you are coding a web app that shows the results of a monitoring process that updates every five minutes. If you know your results will be the same until the next "refresh" in three minutes, you can tell browsers the data will expire in three minutes and prevent them from executing your computationally expensive code until you have something new to report.

If you don't tell the browser how long the data will be valid, it won't know when to refresh from the server and when to display its cached data.

Users commonly expect the Back button to merely return to what was last shown, but this is an example of a user interface not doing what is expected. Refusing to show anything because the old result has expired seems invasive when the cache still holds the last page viewed, but that is a common (standard?) browser behavior.

So, to let the browser keep its results and show them to the user as often as s/he wants, set the expires time in the HTTP header.

# Cache these results for one hour print $cgi->header(expires => '+1h');
There are several cache control headers. See cianoz's answer for examples; see The W3C standard for more information.

Answer: Why does back-buttoning to a cgi script-output page yield 'Page expired'?
contributed by cianoz

maybe http headers sent by the script contains something like:

cache-control: no-cache, must-revalidate pragma: no-cache
if you have the program "wget" you can verify by typing:
wget -S "http://your.url/here"

so as pointed before maybe is a feature...

Please (register and) log in if you wish to add an answer

  • 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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (5)
    As of 2020-08-08 04:32 GMT
    Find Nodes?
      Voting Booth?
      Which rocket would you take to Mars?

      Results (51 votes). Check out past polls.