I have this button to refresh the page
echo '<input type="button" value="Reload Page"
onClick="window.location.href = window.location.pathname;">';
What is the easiest way to make sure that the page is read not from cache? To use Math.random()
Something like
echo '<input type="button" value="Reload Page"
onClick="window.location.href = window.location.pathname&\'?t=\'&Math.random();">';
To reload from server use:
window.location.reload(true)
Info: http://www.devguru.com/technologies/ecmascript/quickref/reload.html
使用Math.random()将起作用,因此(new Date())。getTime()也将起作用。
The most reliable way of doing this is via server side, by setting the header:
Cache-Control: no-cache
See this article for more details.
instead of javascript why not link directly
<?php
echo "<a href='" . $_SERVER['PHP_SELF'] . "&=" . time() . "'>Reload Page</a>";
?>
instead?
Edit :: As i note I only suggest this because you included the sample php within your original post.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.