Apache HTTP server – How to determine on the server if a download finished and of which file

apache-2.2file-transfer

We have an Apache HTTP server up and running, which serves dynamically created zip archives to the users which are possibly several 100s of megabytes in size. As we create a new file with every click on the "download" button (even if the content did not change…), we will most likely run into disc capacity problems.

I have a rather dumb script running that deletes all files that have been created 90+minutes ago. Obviously not that nice of a solution.

I was wondering how to determine from the command line of the server when a download finished, successfully or not. In that case I can delete that file as it will not be served twice. Thinking about it, it might even be sufficient to check if the server is using a file or not as it is created right before it is served to the client.

Thanks!

Best Answer

Since deleting a file that a process has an open file handle on leaves the file there until the handle is closed you could just delete them immediately, and when Apache closes the file it'll be removed from disk.

Related Topic