How to Change a file before you return from the server?

Hello, please tell me how to implement:

You want to give multiple files from the server(using PHP), but the procedure in each file to change the value (date and time), which is written almost at the end (about 1000 bytes to the end) of each file.

If you open the file using file_get_contents to find it (using regular exp-I) date and overwrite it, then an open stream to pass to readfile($file) without saving the modified file on the server?

Or Implemented using fopen() and fwrite() , i.e. Open, Modify, and pass on sending a readfile($file).

P. S. _1 When you open the file using file_get_contents or fopen(), I understand you can set a Negative offset, so that at the end of the file "Faster" to find the desired data for replacement?
(as if the file is more than 300Mb need to look for the date string)

P. S. _2 If the file size is about 200Mb, and multiple connections to the server work this design ?
April 3rd 20 at 17:36
1 answer
April 3rd 20 at 17:38
The very description of the problem suggests that it is better not to decide, to resolve.
Because the returns are huge file that is constantly changing one field - an obvious nonsense, which is best to solve organizational: the data separately, the date and time of loading separately.

If you can't affect anything but your server, you can make a workaround: to score in cron task, which substitutes this file "fresh" with the current time, say, every 5 minutes. And give it the same static.
Apparently I'm not given importance, there is still time, along with the date you need to specify the id of the client from whom the request came.

I did not decide how to do it.
Adjust the replies of the server under client request.
App for clients to modify can't.

Probably have to copy files to, i.e. to Open (completely in memory),
To overwrite data
Send
Close. - Houston_Botsford commented on April 3rd 20 at 17:41

Find more questions by tags PHP