Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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.

In reply to Re: Why does back-buttoning to a cgi script-output page yield 'Page expired'? by Russ
in thread Why does back-buttoning to a cgi script-output page yield 'Page expired'? by dyfn

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2022-08-11 02:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found