Force page refresh on back button

I've tried to force a page to be downloaded again by browser when user clicks back button, but nothing worked. I appears that modern browsers have separate cache for pages, which stores complete state of a page (including JavaScript generated DOM elements), so when users presses back button, previous page is shown instantly in state the user has left it. If you want to force browser to reload page on back button, add onunload="" to your (X)HTML body element:

<body onunload="">

This disables special cache and forces page reload when user presses back button. Think twice before you use it. Fact of needing such solution is a hint your site navigation concept is flawed.

2012-04-13 10:03:02
maybe try to set headers disabling cache, if you have access to the server side, thus a page loaded for the first time won't be cashed by the browser, you can ggogle for appropriate header setting
2012-06-07 08:13:09
Bro, you saved my day.
Note that 'unload' does not work, but 'onunload' works for me.
(on FireFox13)
2013-01-21 11:43:26
Jakub Fedyczak
tomek: it's a different animal. Browsers ignore any headers in some cases.

KiddoKenshin: updated - thank's for the tip.
2013-02-12 11:08:42
thanks, that helps me a lot...
2013-05-23 08:15:40
When someone has pcahisyl access to your computer it is also possible to get around the password in single user mode by using a livecd > mount the system partition and change the password hash in /etc/shadow.So I would also suggest to set a boot password in the BIOS so one would need to reset the bios chip on the motherboard to be able to boot a live medium.Nothing is completely safe but we can try to make it as hard as possible ;)
2013-06-11 00:42:49
Giovanni Ferrari
woooow thank you so much

This is exactly what we needed, I had been looking for a solution to my problem for hours.

Add comment...