i creating a site online university course registration form but. i want, when someone use my site if he can click back button or next button in chrome or any browser then site take auto refresh . Please tell me how that possible.
Asked
Active
Viewed 1,751 times
0
-
Use Cache Control headers. – Indrasinh Bihola May 25 '15 at 10:35
-
1http://superuser.com/q/681072/299159 ? – Sulthan Allaudeen May 25 '15 at 10:37
-
please give some code that can help me... – Al-mahbub Khan May 25 '15 at 10:41
-
1Are you using any framework or core php?? Try This http://stackoverflow.com/questions/13640109/how-to-prevent-browser-cache-for-php-site – Indrasinh Bihola May 25 '15 at 10:42
-
yes it work thanks for your help. but a tiny problem i use check box but when some one add some check box and then he back it my page is now refresh with your code but check box tick is seen ... how i solve this problem?? – Al-mahbub Khan May 25 '15 at 10:48
2 Answers
4
To make sure the response contents aren't cached, you should add a Cache-Control: max-age=0
header to the response, which marks it as uncachable. There are some caveats in that area, but googling on "no cache headers" will make that clear for you.
To make sure the browser doesn't cache the form values (whether or not the response was cached), you should disable autocomplete on the form:
<form ... autocomplete="off">
...
</form>
One step further is to investigate the browser's "history API", which you can hook into using libraries such as Backbone.History.

Gerard van Helden
- 1,601
- 10
- 13
-
wow thanks now my problem is solve in it check box tick is not seen so its help ful it can clear my cache and thanks Indrasinh Bihola and Gerard van Helden – Al-mahbub Khan May 25 '15 at 11:27
2
add this in font page it can refresh page
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
if you use check box then you need to add
<form ... autocomplete="off">
...
</form>
this can clear your check box tick. so if you click back button in mojila or chrome your page will be auto refresh.

Al-mahbub Khan
- 309
- 2
- 10