Perl & Apache: modifying index.html while it's used

B

brendan

hi there,

I have a little Perl script which will run as an Apache CGI script.
This script will modify the contents of index.html.

What happens to users who hit index.html while the script is modifying
it? Will they see a half-constructed page?

What's the best way to ensure that Apache doesn't display the modified
file until it's fully written?

thanks!
 
S

Steve Grazzini

brendan said:
What's the best way to ensure that Apache doesn't display the modified
file until it's fully written?

You could write a temporary file and then close and rename() it.
 
B

brendan

Steve Grazzini said:
You could write a temporary file and then close and rename() it.

Sure, I had a feeling that might be the best approach. Does Apache
cope alright with having a file being renamed like this?
 
G

Greg Miller

Sure, I had a feeling that might be the best approach. Does Apache
cope alright with having a file being renamed like this?

On UNIX you'll be fine, on Windows I don't know. But even if
there is a possibility for a problem to occur, it would be in that
minuscule amount of time it takes to delete the old one and rename the
new one, giving users a 404 error. But it's much better than just
overwriting the file, so users could possibly get a half done file.

Greg Miller (e-mail address removed) http://www.gregmiller.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top