-1

I have a website and I'd like to "bug" it by limiting the load speed (like a 56ko/S connection bandwidth lol)

Is it possible in PHP ? maybe with Header ?

Thanks

Didier
  • 1
  • Yes sorry for my english :p The duplicate is what I was looking for, but I didn't how to mention it. thank you very much. – Didier Jan 02 '18 at 13:09

2 Answers2

-1

Yes, while downloading or processing something you may add a sleep or usleep.

https://stackoverflow.com/a/7406036/6288442

You can use php's sleep($seconds) function to slow down a page load. However, you would need to turn implicit output buffer flushing to "on" with ob_implicit_flush(true); if you want anything to be sent to the user's browser before the page is done being processed. Otherwise your page won't have ANY contents until it's done loading. Calling sleep alone won't do the trick.

C. Geek
  • 347
  • 2
  • 16
-1

It depends on the scenario.

If you want to "test" your code while you're in development, you should use a browser that allows you to set the connection speed. Almost all browsers provide such features, for example, Chrome: https://developers.google.com/web/tools/chrome-devtools/network-performance/network-conditions.

If you want to write something like an automated test, it depends on the infrastructure, i.e. on the webserver.

Like for Apache, there is a module available to decrease the connection's speed for certain requests, mod_ratelimit: https://httpd.apache.org/docs/2.4/mod/mod_ratelimit.html. Install it and configure it for your needs. You could for example, activate it before the test, do the test, then deactivate it again on you local test environment.

weiglt
  • 1,059
  • 8
  • 15