4 messages in ru.sysoev.nginxRe: Can't make nginx to cache
FromSent OnAttachments
Mirosław JaworskiJul 21, 2009 8:03 am 
Gabriel RamugliaJul 21, 2009 12:29 pm 
Mirosław JaworskiJul 23, 2009 5:51 am 
Maxim DouninJul 23, 2009 6:15 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Can't make nginx to cacheActions...
From:Mirosław Jaworski (mj@ikp.pl)
Date:Jul 23, 2009 5:51:42 am
List:ru.sysoev.nginx

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