Question: I'm trying to make a website load forever. My current idea is to request a PHP file:

```php
<?php
sleep(30);

```

This will delay the load by 30 seconds, which a quick Google search tells me should be within most browsers' timeouts. I was thinking of writing some JavaScript to append a new link tag after a bit less than 30 seconds to keep the page loading, but I found that this didn't keep the loading icon spinning (with Chrome at least):

```js
window.addEventListener( 'load', () => {
    var i = 0;
    setInterval( () => {
        i++;
        var newScript = document.createElement('script');
        newScript.src = 'infinite-loading.php?i=' + i;
        document.querySelector('#infinite-loading').after(newScript);
        console.log('The deed is done');
    }, 25000)
} )

```

```html
<script id="infinite-loading" src="infinite-loading.php"></script>

```

The code above appends a script tag every 25 seconds, and the browser loads the PHP file each time, but it doesn't show the loading icon. I added the URL parameter because I wasn't sure if browsers would cache the page.

I also want to make sure that the server with the PHP file won't be overloaded. I'm not sure if many `sleep()` functions running constantly at the same time will cause any issues.

Is there a better way to do this client-side? Should I use something other than PHP? Something multi-threaded?

*(Edit: Sorry for the awkward title, Stack Overflow didn't like my first one.)*

Answer: 
You need that browser will continue reading your page forever (I'm talking about HTML, not other linked objects). So you need not to break timeout and feed some data from backend to frontend.

[Example](https://stackoverflow.com/questions/3133209/how-to-flush-output-after-each-echo-call) of sending portion of data to client:

```php
ob_end_flush();

# CODE THAT NEEDS IMMEDIATE FLUSHING

ob_start();

```

Now we need to understand the minimum data packet size that is expected by the browser. Minimal googling tells us a [limit of 8-10 bytes](https://github.com/Atmosphere/atmosphere/issues/13).

So combining this together we can try to check (I did not checked, it is just my version):

```php
<?php
while (true) {
  sleep(25);
  ob_end_flush();
  echo "          "; // 10 spaces...
  ob_start();
}

```
Not sure why you would want to do anything like this but the simplest solution I think is an endless loop.

```
<?php

while(true)
{

}

```