do not reload

A

anonymous

How do I make sure that a perl CGI page doesn't get reloaded
when the user hits the back button and goes to it? I've
tried outputting the "Expires" header, but that doesn't seem
to do the trick.
 
C

ctcgag

How do I make sure that a perl CGI page doesn't get reloaded
when the user hits the back button and goes to it?

You don't. You let it load, then do something else.
I've
tried outputting the "Expires" header, but that doesn't seem
to do the trick.

Two pages ago, you generate a transaction id and embed that in the page
one page ago. Then the first time they submit, you record this transaction
id. The second time they submit, you look up the id in the database, see
that the transaction id has already been submitted, and write an error
page.

Or you use some modules that do effectively the same thing for you.

Or you let the user do whatever they want, and hold them responsible
for their actions.

Xho
 
B

Bill Smith

How do I make sure that a perl CGI page doesn't get reloaded
when the user hits the back button and goes to it? I've
tried outputting the "Expires" header, but that doesn't seem
to do the trick.

I have had this problem and I think I understand it.

When your user selects his browser's "BACK" button, the browser usually
displays a local copy of the previous page rather than requesting an
update from the server. You probably cannot change this behavior.

I have worked around the problem by providing a button (usually called
"PREV") which does what you intend. I turned out that it was often
useful to have both options available.
 
M

Malcolm Dew-Jones

(e-mail address removed) wrote:
: How do I make sure that a perl CGI page doesn't get reloaded
: when the user hits the back button and goes to it? I've
: tried outputting the "Expires" header, but that doesn't seem
: to do the trick.

Don't use POST. Always use GET if possible. The browser interactions are
more polite for the user, and the semantics of POST cannot be trusted to
work correctly when you need them anyway.
 
A

Alan J. Flavell

Don't use POST. Always use GET if possible.

If this was a CGI group, I'd go into detail about why I thought that
was poor advice in the form in which it's offered. There sure can be
situations where it's the right answer; but to offer it as a general
rule seems to provoke far more problems than it could possibly solve.

sorry.
 
B

Big and Blue

Bill said:
I have had this problem and I think I understand it.]

But it is not a Perl problem - it is an HTTP one.
When your user selects his browser's "BACK" button, the browser usually
displays a local copy of the previous page rather than requesting an
update from the server. You probably cannot change this behavior.

The browser does not usually display a local copy. It depends on how
the browser is configured. It may be set to check on each loading, check
once per session, always assumethe cache entry is valid, etc.. This
setting *is* client depending and you can't affect it.
I have worked around the problem by providing a button (usually called
"PREV") which does what you intend. I turned out that it was often
useful to have both options available.

It would be interesting to know what this button did that was so
different to the user clicking on "Back".

This really is all to do with the HTTP protocol. The best thing to do
is probably something like:

a) Send an Expires header. Although look up HTTP1.0 vs. HTTP1.1
differences here, and various things you may also wish to set for proxying
and caches.

b) Handle IfModifiedSince headers (of course, you will have to decide
whether the content would have changed since the time the client sends).
(The relevant reply if no change is needed is just to send back the
relevant HTTP status, but I can't remember what that is at the moment.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top