Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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=perlquestion: print w/replies, xml ) Need Help??

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

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.

Originally posted as a Categorized Question.

  • Comment on Why does back-buttoning to a cgi script-output page yield 'Page expired'?
  • Download Code

Replies are listed 'Best First'.
Re: Why does back-buttoning to a CGI page yield 'Page expired'?
by Anonymous Monk on Feb 15, 2000 at 16:57 UTC
    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?

Re: Why does back-buttoning to a cgi script-output page yield 'Page expired'?
by DarkSniper (Initiate) on Feb 17, 2003 at 12:48 UTC
    i solved this by setting the expiry time on all my headers to +1h.
    print $cgi->header(expires => '+1h');

    Originally posted as a Categorized Answer.

Re: Why does back-buttoning to a cgi script-output page yield 'Page expired'?
by Russ (Deacon) on Jan 11, 2007 at 23:25 UTC

    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.

Re: Why does back-buttoning to a cgi script-output page yield 'Page expired'?
by cianoz (Friar) on Aug 26, 2000 at 16:22 UTC
    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...

Re: Why does back-buttoning to a cgi script-output page yield 'Page expired'?
by Zecho (Hermit) on Aug 24, 2001 at 11:26 UTC
    Oops, scratch that first one.. I did say I was a newbie right?

    if $hidden_string eq "true"{ &dothis; }
    To avoid all the problems with hitting the back button, I changed it to this
    if $hidden_string eq "true"{ $hidden_string = ""; &dothis; }

    Originally posted as a Categorized Answer.

Re: Why does back-buttoning to a cgi script-output page yield 'Page expired'?
by Zecho (Hermit) on Aug 24, 2001 at 11:24 UTC
    I'm still a newbie, but I ran into this yesterday. I wanted to be able to return from a sub that required a variable to be set

    if $hidden_string eq "true"{ &dothis; }
    To avoid all the problems with hitting the back button, I changed it to this
    if (defined($hidden_string)){ $hidden_string = ""; &dothis; }

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://3436]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2022-06-25 11:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (81 votes). Check out past polls.

    Notices?