lua-resty-redis
lua-resty-redis copied to clipboard
Main request hangs with multiple SSI subrequests
Hello,
After reading the issue #23 I have updated my configuration to the following: https://gist.github.com/frozenminds/5a1f0b9047c7af69ec61
Each SSI request will try to get the content from Redis, if key is not saved in cache yet, it will fallback to a PHP route which will generate the content, save it to Redis and return the output. The second time, Nginx will retrieve the content from Redis because it was cached.
On a page I have 4 SSI calls. The last one hangs on the very first request before the page is also stored in Nginx's FastCgi cache.
<!-- include virtual="/ssi?action=a -->
<!-- include virtual="/ssi?action=b -->
<!-- include virtual="/ssi?action=c&product_id=123 -->
<!-- include virtual="/ssi?action=c&category_id=999 -->
I am aware of this: http://wiki.nginx.org/HttpLuaModule#Mixing_with_SSI_Not_Supported But what I do not understand, do I have to completely turn off the SSI module and write my own module that will parse the SSI tags () and then use ngx.location.capture or ngx.location.capture_multi the get the content?
If I do have to parse the SSI tags, do you have any idea where do I start from? Could you please guide me further?
Thank you in advance! Boby
@frozenminds You don't have to remove ngx_ssi from your nginx build. You just need to avoid mixing ngx_ssi's configurations with ngx_lua's in the same main request.
What do you have in your conf.d/server/fastcgi_params.conf file? And what versions of ngx_lua and nginx are using? Are you using my openresty bundle?
BTW, please avoid using the word "ssi" in your configurations where ngx_ssi is not used at all. That is very confusing.
Hi @agentzh ,
First of all thank you for the quick reply.
I am using ngx_openresty-1.5.8.1, seems like the latest. Also tried with ngx_openresty-1.4.3.6.
Added now also the fastcgi_params.conf file to my Gist: https://gist.github.com/frozenminds/5a1f0b9047c7af69ec61#file-fastcgi_params-conf
I do have in my main request some small Lua's: set_by_lua_file, rewrite_by_lua_file and header_filter_by_lua_file. None of them is making any other sub-request or big stuff. Just very basic IF/ELSE.
Thank you!
@frozenminds Thank you for the info! I have several suggestions for you:
- Please try creating a minimal but still complete example that can reproduce the issue. It'll be trivial for me to analyze the issue if I can reproduce it on my side :) You'd better use ngx_proxy instead of ngx_fastcgi if you can in your minimal test case because I don't want to run a fastcgi backend to run your example, which is quite a burden for me.
- Failing that, please enable nginx's debug logging in your openresty build (by specifying
--with-debugfor./configureand use thedebuglevel in yourerror_logdirective) and provide all the debug logs for the problematic request. See also http://nginx.org/en/docs/debugging_log.html
Thanks!
@agentzh I will try to create an example for you. Hopefully tomorrow.
Thank you very much!
Still haven't finished the setup :( Would you mind to get access via SSH to an already configured server?
Thanks!
@frozenminds No, I don't mind. Please send me details privately to my email address, agentzh at gmail dot com :)
Seems to be something else actually. Will try to fix the code that I suspect and get back to you.
I have the same problem!
Could you tell me the Solutions!
Thank you @agentzh
@KunkkaCoco The NGINX SSI module is complicated and error prone. Better use ngx_lua to do the content templating instead. For example, with Lemplate:
https://github.com/openresty/lemplate