0

I have a CentOS release 6.6 (Final) distro on which is running a Varnish instance (port 80) and Apache 2.2 (port 81).

Apache reads file from a NFS.

The issue I am facing (not always but most of the time) is the following: if a create a new file on the NFS and I try wget that file directly on port 81 (bypassing Varnish), Apache is giving a 404.

--2018-08-03 16:11:28--  http://www.example.com:81/test/lorem-ipsum-2/index.html
 Resolving www.example.com... ::1, 127.0.0.1, 10.xxx.xxx.xxx
 Connecting to www.example.com|::1|:81... connected.
 HTTP request sent, awaiting response... 404 Not Found
 2018-08-03 16:11:29 ERROR 404: Not Found.

Only after about one minute it is able to return 200 with the file content.

wget "http://www.example.com:81/test/lorem-ipsum-2/index.html"
--2018-08-03 16:12:40--  http://www.example.com:81/test/lorem-ipsum-2/index.html
Resolving www.example.com... ::1, 127.0.0.1, 10.xxx.xxx.xxx
Connecting to www.example.com|::1|:81... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4524 (4.4K) [application/json]
Saving to: “index.html”

100%[===================================================================================================================================================================================================>] 4,524       --.-K/s   in 0s

2018-08-03 16:12:40 (122 MB/s) - “index.html” saved [4524/4524]

In addition it might be important to say that if I do a cat on that file before one minute passes, Apache is than able to return 200 OK.

cat /data/nfs_shared/httpd/htdocs/test/lorem-ipsum-2/index.html

Maybe someone can help on this.

Thanks

1 Answers1

0

NFS caches by default for performance reasons.

If you don't want to wait a minute, you can mount the share without directory caches: acdirmin=0,acdirmax=0

NFS - Detecting remotely created files programmatically?

John Mahowald
  • 32,050
  • 2
  • 19
  • 34