unlink("cache/data.xml");
I feel that this may generate an error at times when sever might be reading and serving it to the visitor.
how to safely delete the file so script will continue to wait until the read lock from the web server is released if any and then continue deleting the file or how it works out there?
Thanks
This will depend on the specific system this is running on, but the man page for the UNIX
unlinkfunction (which the PHPunlinkfunction very likely relies on internally) says this:In other words, the process reading the file can continue to do so, even while the file is being deleted.