Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directives srcache_store_pass_header didn't work #72

Open
ricardo-ml opened this issue Jul 3, 2018 · 2 comments
Open

Directives srcache_store_pass_header didn't work #72

ricardo-ml opened this issue Jul 3, 2018 · 2 comments

Comments

@ricardo-ml
Copy link

ricardo-ml commented Jul 3, 2018

HI,
I use srcache-nginx with memcached. i read your "README.markdown" then i know by defult command "srcache_store PUT /memc $key" can't store if http header have "Connection:keepalive" . so i add command "srcache_store_pass_header" to force store, but it isn't work.

My nginx.conf:
location = /memc {
internal;
set $memc_key $query_string;
set $memc_exptime 600;
memc_pass 127.0.0.1:11211;
}

location / {
set $my_key $request_uri;
srcache_fetch GET /memc $my_key;
srcache_store PUT /memc $my_key;
srcache_methods GET HEAD POST;

srcache_store_pass_header Connection;
srcache_store_pass_header Set-Cookie;
srcache_store_pass_header Keep-Alive;
srcache_store_pass_header Proxy-Authenticate;
srcache_store_pass_header Proxy-Authorization;
srcache_store_pass_header TE;
srcache_store_pass_header Trailers;
srcache_store_pass_header Transfer-Encoding;
srcache_store_pass_header Upgrade;

add_header X-Cached $srcache_fetch_status;
proxy_pass http://web_servers;

}

Test Result( I already exec twice ):
[root@test ~]#curl -I http://192.168.0.214/a.html
HTTP/1.1 200 OK
Server: Nginx/1.8.1
Date: Tue, 03 Jul 2018 02:35:10 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 42
Connection: keep-alive
Last-Modified: Wed, 27 Jun 2018 07:08:38 GMT
ETag: "2a-56f9a48ab6919"
Accept-Ranges: bytes
X-Cached: MISS

Memcached Result:
[root@test ~]#telnet 127.0.0.1 11211
get /a.html
END

Can you help me to fix this problem?

@ricardo-ml
Copy link
Author

ricardo-ml commented Jul 3, 2018

i tested by nginx 1.14.0. it have same problem
This is debug log:
2018/07/03 14:27:37 [debug] 8877#0: *4 http upstream request: "/a.html?"
2018/07/03 14:27:37 [debug] 8877#0: *4 http upstream process header
2018/07/03 14:27:37 [debug] 8877#0: *4 malloc: 0000000000E69480:4096
2018/07/03 14:27:37 [debug] 8877#0: *4 recv: eof:1, avail:1
2018/07/03 14:27:37 [debug] 8877#0: *4 recv: fd:11 260 of 4096
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy status 200 "200 OK"
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy header: "Date: Tue, 03 Jul 2018 06:27:36 GMT"
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy header: "Server: Apache/2.4.6 (CentOS)"
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy header: "Last-Modified: Wed, 27 Jun 2018 07:08:38 GMT"
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy header: "ETag: "2a-56f9a48ab6919""
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy header: "Accept-Ranges: bytes"
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy header: "Content-Length: 42"
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy header: "Connection: close"
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy header: "Content-Type: text/html; charset=UTF-8"
2018/07/03 14:27:37 [debug] 8877#0: *4 http proxy header done
-->2018/07/03 14:27:37 [debug] 8877#0: *4 srcache_store skipped due to request method HEAD<--
2018/07/03 14:27:37 [debug] 8877#0: *4 http script var: "MISS"
2018/07/03 14:27:37 [debug] 8877#0: *4 HTTP/1.1 200 OK
Server: nginx/1.14.0
Date: Tue, 03 Jul 2018 06:27:37 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 42
Connection: keep-alive
Last-Modified: Wed, 27 Jun 2018 07:08:38 GMT
ETag: "2a-56f9a48ab6919"
Accept-Ranges: bytes
X-Cached: MISS

@mbtamuli
Copy link

Note that since the v0.17 release HEAD requests are always skipped by srcache_store because their responses never carry a response body.

https://github.com/openresty/srcache-nginx-module#srcache_methods

I believe the MISS is because you're using curl -I,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants