tags:

views:

30

answers:

1

Hi,

I am trying to make a cache class that makes url into a static file. When I click 'Cache' button on the backend, it might cause users to see error on their browsers since files do not support lock. Am I correct???

+1  A: 

I'm assuming you're concerned that when a file is in the process of being cached (i.e. being written to) there may be problems with Apache trying to read from the file which may result in Apache returning an error that is subsequently displayed in a browser..

I don't believe you're correct, but this may depend on the operating system and web server being used.

Under Linux + Apache, I've observed the following behaviour:

  1. You can't write to a file whilst Apache has the file open for reading

    For example, if you are uploading a file via FTP and that same file is being read by Apache, you can't complete the write until Apache has finished reading the file.

  2. Apache can't read from a file whilst the file is open for writing

    In such contexts, Apache appears to wait until the write is complete.
Jon Cram
then..it means it is safe!
Moon