Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The problem with nginX caching happened when I used ntpdate to sync my server clock.

Now when I request the path I receive the old PHP file that I was working on.

I tried to set sendfile to off in nginx.conf and even turned off caching in cloudFlare for my DNS, but gain no success.

When I looked into the header part with curl -I I had the below response:

HTTP/1.1 302 Moved Temporarily                                                 │
Server: nginx                                                                  │
Date: Fri, 15 Aug 2014 10:51:38 GMT                                            │
Content-Type: text/html                                                        │
Connection: keep-alive                                                         │
Set-Cookie: PHPSESSID=cihsfrq6aoat5baun8dem01go5; path=/                       │
Expires: Thu, 19 Nov 1981 08:52:00 GMT                                         │
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0  │
Pragma: no-cache                                                               │

I couldn't find any nginx cache folder to delete. I've restarted nginX after all those changes but gained nothing. I cannot think of any other reason why this is happening.

Is seems that when I use ntpdate, it changes server time to 7:25 while my time is 16!? File modifications are now 16, the old date, while my system time is 7:25. If I change my time to 16 then my pusher will throw an error and says that timestamp given is expired:

string(112) "Timestamp expired: Given timestamp (2014-08-15T20:06:20Z) not within 600s of server time (2014-08-15T11:39:59Z) " 
share|improve this question
up vote 0 down vote accepted

You might have APC cache module installed in PHP. The easiest way to force APC cache refresh, you should restart your PHP-FPM daemon.

share|improve this answer
That solved my problem. service php5-fpm restart did the job. – Alireza Hos Aug 15 '14 at 17:12

Cache times are built using the current system time. Time jumps such as you experienced are expected to create strange behavior. nginx is just one of several programs which can behave this way. These issues generally clear, once the times catch up.

Try running an ntp daemon process rather than periodically running ntpdate. One advantage of ntp over ntpdate is that for smaller adjustments it will slew the clock rather than jump the clock. Once your clock is in sync, ntp will query its servers roughly every 15 minutes (1024 seconds).

If you know your clock is significantly off, then you can manually adjust the clock in small adjustments over a long period of time. This could be scripted and run as a cron job. Once you are within a minute or so of the real time, then you can start your ntp daemon.

share|improve this answer
ntp keeps the current time in sync? Is that what you say? For example if I set the server time to 16 then ntp keeps that time in sync? I think I'm missing something? What is the role of ntp daemon? – Alireza Hos Aug 15 '14 at 13:33
NTP constantly polls the NTP servers assigned to it, and makes sure that the local computer time is correct. – Tero Kilkanen Aug 15 '14 at 13:51
@TeroKilkanen Yes, NTP poles its servers and adjusts the local clock to keep it correct. In most cases, this can be done by polling every 1024 seconds. My hosts are kept withing a few milliseconds of the correct (atomic) time. – BillThor Aug 15 '14 at 21:55

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.