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

This is my first post here and I'm hoping that someone can help me.

I have a CGI script that creates a dynamic form. When the user fills in the required information it is then sent to the server for processing. Then a new page is returned to the user that is "updated". What I need to do is prevent the user from using his back button and obtaining the last cached page.

Here's the code I used:

print header(-type => 'text/html', -expires =>'-1d', -cookie => $Some_information, -Pragma => 'no-cache', -Cache_Control =>'no-store,no-cache,must-revalidate,post- +check=0,pre-check=0');

This works great in Firefox, but it DOESN'T work in IE or Opera. What's my problem? By the way, before testing, I deleted all of each browser's cache. If any of you could offer any help I sure would appreciate it.

Thanks in advance...Mike

Replies are listed 'Best First'.
Re: Control of cache
by Aristotle (Chancellor) on Sep 17, 2004 at 07:04 UTC

    I took a look back at the stuff I put in my overkill anti-caching CGI headers, and you have all that except for the Last-Modified header. Maybe adding that will help?

    IE at the very least is known to be rather… idiosyncratic about its decisions to use or not use a cached copy of a page, though — including cached copies of some headers.

    Makeshifts last the longest.

Re: Control of cache
by samtregar (Abbot) on Sep 17, 2004 at 22:21 UTC
    As far as I know you can't prevent IE from using its cache in all situations and you can't "turn off" the back button. Thus, if you really need this functionality you'll have to do it the hard way: put a serial number in each form and keep track of which form numbers have been submitted in the user's session. If the user tries to submit the same number twice then you know they went back. I think this is how Citibank's online banking system works, but I haven't looked too close.

    -sam

      Thanks for responding.

      You must be right...I've tried everything!

Re: Control of cache
by chanio (Priest) on Sep 18, 2004 at 03:20 UTC
    Erasing the history, and later, reestablishing it?

    .{\('v')/}
    _`(___)' __________________________
    Wherever I lay my KNOPPIX disk, a new FREE LINUX nation could be established.