I am wondering how I can create a http module that generates dynamic content and starts sending the response as soon as it is ready so it does not have to buffer the entire content locally and also to prevent hitting timeout issues because it might take quite a bit of time until the last byte of the response is generated.
Hey @enshin! There is no easy answer. You would need to create a custom module. We have some documentation around it but it is not a trivial process. You would have to write code in pure C.
I will say however that NGINX is not really a tool to be used to generate dynamic content. What type of content do you have in mind? The real solution here would be to use an external tool and use NGINX as a proxy in front of the tool. You should be able to then use NGINX directives to start streaming the data back to the client immediately and customize the timeout time per your discretion.
I’d use this module to create dynamic content that originates from SQL queries to a database.
I am prepared to using C (in fact, the the database access is also written in C).
It is certainly possible to use nginx as a reverse proxy to the web server that accesses the database, but an approach where the webserver also crreates the content in one go seems more straight forward to me.
If you are fine with C then by all accounts go for it! It should be doable. The link I shared in my previous post is still the best source of information we have around building modules, especially the adding new modules section. It won’t be easy, but keep us updated!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.