Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
How to speed up PHP's write to file time?
I’ve just made the switch from GoDaddy’s Shared Hosting to DigitalOcean and their write to disk through PHP appears to be much faster, is there any way of speeding this up?
fwrite($retrieve, $replace); fclose($retrieve); header('Location: ./');
The code above will write a certain piece of data to a specified location before refreshing the page. The problem is, when the page is refreshed, the data hasn’t been finished writing to so the user will see the old data on the page. He will have to refresh the page again to see the updates.
With GoDaddy’s Shared Hosting (using the same piece of code above), the user would be redirected through
header after the new data has been written to the file so the user will see the updated contents immediately, rather than having to refresh the page again.
Is there something I’m doing wrong? Is there a way to speed up the write to file time?
I am currently on DigitalOcean’s $5/month plan and I would really appreciate any help on this, thanks!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×