0

I know you can refresh the page instantly in PHP using header("refresh: 0;");

You can also put your own delay, i.e. 3 seconds like this header("refresh: 3;");

My question is, is it possible to put a delay of less than one second, i.e. one tenth of second? header("refresh: 0.1;");

  • 1
    As far as I know, that header only works with full seconds. If you want shorter, you can always use JS to redirect the page in a [setTimeout()](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) (where you can define milliseconds). May I ask why you would need the page to refresh after 0.1 sec? – M. Eriksson May 09 '22 at 07:45
  • What would be the use case for a 0.1 second refresh? I'd guess a user wouldn't see a difference in an immediate refresh and a 0.1 second delay – brombeer May 09 '22 at 07:46
  • using PHP to manage a database. need the page to refresh after for example adding an entry to a table (so it can display the table with the newly added data). The server is kind of slow, so I need a delay greater than 0 but less than a second for convenience – Vincent Cerowski May 09 '22 at 07:47
  • The more common/modern way of doing that would be to make the request using Ajax and only reload the table (using JS/Ajax) without reloading the entire page. – M. Eriksson May 09 '22 at 07:49
  • _"The server is kind of slow"_ - Are you saying that you won't get the new data stored in the database if you redirect directly? That sounds odd. When your script is done inserting the data, it should be available immediately. – M. Eriksson May 09 '22 at 07:53
  • You could perhaps use the `sleep` or `usleep` to add a small delay – Professor Abronsius May 09 '22 at 07:58

2 Answers2

0

Tried it and it works

For example: header("refresh: 0.25;"); header("refresh: 0.1;"); header("refresh: 0.75;"); header("refresh: 0.5;"); all seem to work.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 10 '22 at 07:17
0

header("refresh: 0.9;"); will refresh instantly, header("refresh: 1.9;"); will refresh after 1 second and so on. Decimals are ignored.

daniel
  • 1
  • 1