Strange problem with cache

Maxim Dounin mdounin at mdounin.ru
Fri Oct 26 10:41:43 UTC 2012


Hello!

On Thu, Oct 25, 2012 at 04:34:14PM -0400, florian.iragne wrote:

> Hi,
> 
> i've come accross a strange problem of caching. My site is run by nginx
> 1.2.1, on two different servers. The config are exactly the same (i use
> puppet to mirror configs). The contents are exactly the same, everything
> that i can think of is exactly identical on both servers.
> 
> In the config, i set "expires max" for the /static location.
> 
> The two nginx are behind a haproxy instance for loadbalancing and failover.
> The setup is in active-active mode.
> 
> When i load a page with no browser cache, each item in the static location
> is served by nginx with the correct response regarding the max-age and
> expire directives. Then i reload the page : some of these ressources are
> served with a 304 response (that is the expected behaviour), some with a 200
> code (hence, a fresh copy of the file). If i reload the page again and
> again, the ressources served with 304 answer are varying.
> 
> Now, i've put the server into active-backup mode, and only one instance of
> nginx is serving the files. In this setup, the ressources are always served
> with a 304 answer.
> 
> Did i miss something? I assume that my servers setup is quite common, and i
> d'ont believe that the behaviour i observe is "normal".
> 
> Any idea?

Symptoms suggest last modification times are different for the 
same static file on different servers.

You have to sync files between servers with modification time 
preserved for conditional requests to work correctly ("rsync -a" 
is usually a good starting point).

-- 
Maxim Dounin
http://nginx.com/support.html



More information about the nginx mailing list