0

I am currently using a redirect band-aid in the header, but I need a stronger solution and I need to know why the Refresh button does not work normally. I have tried many solutions, this is the only one that keeps the page updated:

<?php
$randURL = rand(1000000,1000000000);
echo "<meta http-equiv=\"refresh\" content=\"60;URL=http://anywebsite.php?noval=".$randURL."\">";
showdev
  • 28,454
  • 37
  • 55
  • 73
  • caching: browser, host, any server along the chain, ISP, firewall\router. there's no guaranteed way of not getting a a cached page –  Feb 14 '18 at 21:47
  • The refresh button doesn't work at all? Or do you mean the page refreshes but shows cached content? – showdev Feb 14 '18 at 21:48
  • The page reverts to an older page, so yeah, probably cached, but often many hours old. Should I stick with the solution I mentioned? I tried putting and other tags in the header but none worked. Only the random number solution worked. – user2299779 Feb 14 '18 at 21:52
  • This might be helpful: [How to control web page caching, across all browsers?](https://stackoverflow.com/questions/49547/how-to-control-web-page-caching-across-all-browsers) – showdev Feb 14 '18 at 21:55
  • I am using PHP to generate the page and have tried the header() function but I get errors even if I put it at the top of the page. Any suggestions about how to impliment? e.g. I get an error from, header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1. header("Pragma: no-cache"); // HTTP 1.0. header("Expires: 0"); // Proxies --Error is Cannot modify header information - headers already sent by – user2299779 Feb 14 '18 at 22:06
  • This covers that error pretty extensively: [How to fix “Headers already sent” error in PHP](https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php). One method I've used when data must stay fresh is to load dynamic content using AJAX, and refresh the content without refreshing the page. Are you able to use jQuery (or JavaScript in general)? Is that too deep a rabbit hole? – showdev Feb 14 '18 at 22:14
  • showdev, thanks, looks helpful, will get into it more soon. Getting rid of the white space at beginning and end eliminated the error but still getting old cache when I refresh the page, so Now I need the right header() code. My original solution still works best, although could be a problem if one of the url variables is pulled twice in the refresh period. – user2299779 Feb 14 '18 at 23:53

1 Answers1

0

This is normal behavior, if browser cache is enabled. Ctrl+F5 refreshes the page without using the cache, therefore it works for you.

hg.m
  • 45
  • 4