I am trying to hard-refresh my page, since I randomize the order of my database, but when I refresh the page via the html button it doesn't work, until a bit of time has passed. I assume it is due to the web-browser's cache. it also doesn't work if I refresh it via f5, but if I use shift+f5 it works.
<?php
if(isset($_GET["genre"])) {
$db = mysqli_connect("localhost","localhost","","test","3306");
$genre = $_GET["genre"];
$sql = "SELECT tittel, aar, id, genre, plot FROM gruppe3_film WHERE genre LIKE '%$genre%' ORDER BY RAND()";
$resultat = mysqli_query($db, $sql);
$rad = mysqli_fetch_assoc($resultat);
$tittel = $rad['tittel'];
$aar = $rad['aar'];
$id = $rad['id'];
$plot = $rad['plot'];
echo "
<h2>$tittel ($aar)</h2>
<br><a href='javascript:location.reload();'><img src='../image/DBFilmCover/$id.jpg'></a>
<h4>$plot</h4>
<hr><button><a href='javascript:location.reload();'><div class='black'>New Random $genre Movie</div></a></button>";
?>
As you see I currently use <a href='javascript:location.reload();'>
, but I have also tried javascript:window.location.href=window.location.href
inside href
Using html4
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
Using php
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0");