Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
in Q2A Core by
edited by

I don't know if anybody noticed already, but in some cases navigating back in q2a brings up:

document expired


Only clicking "Try Again" which resends the data to the former site solves this issue.

But knowing users (and myself) I close the site when I get such an error message.

Question: Any way to prevent this?


PS: One example how you get the "document expired": Go to a q2a-site, logged out, then ask anonymously (just give a title), scroll down and use the link at "To avoid this verification in future, please log in or register.". Afterwards clicking the link, navigate back. that's it, you get the expired.

Q2A version: 1.5.1
I can't reproduce this here so perhaps it's a server configuration issue?
Tested on Firefox and Chrome on this site as well, same error:

1. Logout
2. click on "Ask a question"
3. click on "login" at the bottom of the question site
4. use back arrow in your browser
5. document expired
I went through those steps in both Firefox and Chrome on this site, and couldn't reproduce the problem. My guess is that somewhere along the way the HTTP headers are being messed with, perhaps an ISP proxy?
"ISP proxy" I have no idea how I can find out about.

But strange enough that you don't get the same error. Maybe another member can perform steps 1 - 5 and confirm?
I confirm this problem many time. There are couple of things I have noticed. This issue appears especially when we submit any form or we pass dynamic data in theme or plugin for the page.

I would request to put this on high priority. It is most problematic for mobile users where they use back button most of the time.
Thanks for your confirmation Jatin. Appreciated!
Searched a bit and found this proposed "solution":

<?php session_cache_limiter('private_no_expire'); // must go before session start session_start(); ?>
For details, see http://php.net/manual/en/function.session-cache-limiter.php

Found here: https://support.mozilla.org/en-US/questions/922734?page=2

More possible solutions and info here: http://stackoverflow.com/questions/10795552/php-document-expired

Code for post-redirect-pattern:
// dataIsValid should set $message to show to the user
} else {
    $postedData = $defaultValues;
showForm($postedData, $message);

from http://stackoverflow.com/a/19188306/1066234

1 Answer

+1 vote
Just put in your main file this code

<?php header("Cache-Control: max-age=300, must-revalidate"); ?>

it solve it definatly