Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have installed nginx, and things work very well for production, but I sometimes have this problem when developing.

To reproduce the problem, I have done the following:

Create a file in a public folder named test.html with the text "hello".
Open test.html in a browser, correctly displays "hello".
Modify file test.html to contain text "hello world".
Load the webpage, still says "hello".

My first guess was that my browser was caching this, but I tried clearing the cache, and even using a different browser, or just raw wget, but it's all the same.

I investigated the access logs, and found that when the change was made, it is indeed being noticed, because there are two accesses with status 200, and any subsequent reloads without changes is 304.

Also, the server is running in a virtual machine and getting the files from a linked folder, so I suspected that perhaps the VM could not see the file correctly, but loading it up in the VM shows the changes fine.

Restarting nginx does not help, either. Restarting the entire VM does, but this would be terrible to have to do every time. New files are reflected fine, it's just modifications to existing files that is troublesome. To the best of my knowledge, I have not set up any kind of caching.

My suspicion is that nginx is doing some kind of caching, either on disk or in memory, and despite noticing that the file has changed, it still returns the old cached version when asked.

Just looking for some possible solutions?

--Update--

I looked through the configuration files and found something I didn't understand that looked fishy:

sendfile on;

Commenting out this line fixes the problem. Can somebody explain what this does better than http://articles.slicehost.com/2007/12/13/ubuntu-gutsy-nginx-configuration-1/ ?

--Update 2--

Information added to the Nginx wiki: http://wiki.nginx.org/Pitfalls#Config_Changes_Not_Reflected

share|improve this question
1  
1  
Sendfile just means your OS is in charge of sending the file instead of Nginx doing it. It should absolutely not cache files in any way. –  Martin Fjordvald Feb 4 '11 at 18:49
    
ah thank you for this. –  Kevin J Dolan Feb 4 '11 at 18:50
    
My guess is that the sendfile mechanism is somehow broken for the VM implementation of the shared directories. I can just disable this in development... –  Kevin J Dolan Feb 4 '11 at 18:51
    
Kevin, you did not specify which OS you are using. You did not show your Nginx configuration either. Frankly, it's very hard to help you without these relevant bits of information –  Alexander Azarov May 29 '11 at 19:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.