openresty / srcache-nginx-module

Transparent subrequest-based caching layout for arbitrary nginx locations.
http://wiki.nginx.org/NginxHttpSRCacheModule
475 stars 104 forks source link

What to use for SSI/ESI like feature? #35

Open frozenminds opened 9 years ago

frozenminds commented 9 years ago

Hello,

I am working on a project where I need an SSI/ESI like feature. For full page cache I am now using the srcache-nginx-module with Redis and a PHP backend. There will be at least 3 blocks per page which I need whole-punched with something like SSI/ESI and these will also be cached.

SSI does not play well with Lua, on the other hand if I am using SSI with srcache_fetch only then it won't work on my sub-requests.

What would be a good (elegant and also performance wise) approach to replace SSI/ESI tags in both the backend and srcache_fetch responses? Liked replace-filter-nginx-module, but it does not support Lua replacements which I need.

I've done some research and testing, but none worked so far:

Thank you in advance!

agentzh commented 9 years ago

@frozenminds For such fancy requirements, I suggest you go with pure Lua solutions without using such complicated combinations of nginx C modules.

You can do complicated streaming upstream and downstream communications, template-based content generation, remote/local data caching of various levels of granularity, and much more in your single content_by_lua handler with pure Lua.

BTW, it's worth mentioning that the body_filter_by_lua is invoked on each response body data chunk, so you need a proper state machine to take aribitrary chunk boundaries into account (just like the ngx_sub_filter and ngx_replace_filter modules, which are nginx output filters themselves).

Believe me, messing up with complicated nginx subrequests and SSI can never be an enjoyable experience :)

BTW, you're recommended to join the openresty-en mailing list for such general discussions. Please see this page for more details: http://openresty.org/#Community Thanks for your cooperation.

frozenminds commented 9 years ago

Hi @agentzh,

Thanks for pointing me to the pure Lua direction and for the idea to continue the discussion on the mailing list.

I've posted the same question there. We can close this issue here.