Can't make nginx to cache

Mirosław Jaworski mjaw at ikp.pl
Thu Jul 23 16:52:05 MSD 2009


On Tue, 2009-07-21 at 12:29 -0700, Gabriel Ramuglia wrote:
> Edit your php script to send caching headers
> 
> "X-Powered-By: PHP/5.2.6-2ubuntu4.2"
> 
> PHP by default does not send headers that would cause a browser or
> cache to decide that a result was cachable. This makes sense, as php
> is a dynamic language and the same url could return something
> dramatically different every time.

I find this explanation very unlikely:
- nginx source doesn't show any dependence on (not) caching based on
  X-Powered-By header
- nginx can ignore caching-specific headers ( proxy_ignore_headers ),
  X-Powered-By is not on the list
- it doesn't cache static files too:

Direct connect to backend:

$ telnet 192.168.10.18 80
Trying 192.168.10.18...
Connected to 192.168.10.18.
Escape character is '^]'.
GET /test.html HTTP/1.1
Host: www.xyz.pl

HTTP/1.1 200 OK
Date: Thu, 23 Jul 2009 11:52:23 GMT
Server: Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.2 with Suhosin-Patch
mod_ssl/2.2.9 OpenSSL/0.9.8g
Last-Modified: Thu, 23 Jul 2009 11:52:10 GMT
ETag: "cca18-5-46f5e1e220e80"
Accept-Ranges: bytes
Content-Length: 5
Vary: Accept-Encoding
Content-Type: text/html

test
Connection closed by foreign host.


Connect to frontend ( nginx ):
$ telnet A.B.C.D 80
Trying A.B.C.D...
Connected to A.B.C.D.
Escape character is '^]'.
GET /test.html HTTP/1.1
Host: www.xyz.pl

HTTP/1.1 200 OK
Server: nginx
Date: Thu, 23 Jul 2009 11:55:00 GMT
Content-Type: text/html
Connection: keep-alive
Last-Modified: Thu, 23 Jul 2009 11:52:10 GMT
ETag: "cca18-5-46f5e1e220e80"
Accept-Ranges: bytes
Content-Length: 5
Vary: Accept-Encoding

test
Connection closed by foreign host.

  Cache is still empty.

- last but not least, my initial post didn't come from some single
  object testing, it's a tiny part of broader picture, which is:
  - old environment
    - squid as caching reverse proxy, lots of caching ( without it old
      environment would be dead due to lack of backends capacity )
    - some virtual machines ( backends ) with numerous web services
      with tens of thousands documents, including thousands of static
      files ( graphics css js ) with noticeable traffic ( billions 
      visits per month )
  - new environment
    - nginx as caching(?) reverse proxy
    - 1:1 copy of all virtual machines from 'old environment'
  - new environment receives production traffic for couple days already
  - anytime i check it, nginx cache has _zero_ objects inside ( there's
    not even one nested directory inside cache path it should create )

Therefore i believe i lack something to effectively turn the caching on.

Regards

MJ

-- 
Mirosław "Psyborg" Jaworski
GCS/IT d- s+:+ a C++$ UBI++++$ P+++$ L- E--- W++(+++)$ N++ o+ K- w-- O-
M- V- PS+ PE++ Y+ PGP t 5? X+ R++ !tv b++(+++) DI++ D+ G e* h++ r+++ y?
            "Experience is a good school, but the fees are high."






More information about the nginx mailing list