Avoiding the back button or cache

You can add some headers that try to prevent reading cache, but a trick I learned is to append a random variable to your script url's. This way the server thinks you are always going to a different page and doesn't load you're cache. You can use something like

myscript.php?rand=2lkj3lkj99je9j9jef

I generate my random variable within PHP or JavaScript with something like,

/* PHP */
$random_variable = 'rand=' . md5(rand(0,999999) . date("Y-m-d H:i:s");

/* JavaScript */
var random_variable = parseInt(Math.random()*9999999999999);

I just append $random_variable to all of my URL's.

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.