As a proof-of-concept I'm trying to replicate, with nginx and Lua, a complex Apache configuration that includes a URI/request rewriter (originally written in Python), proxy caching, and some other things. So far so good: URI rewriter in Lua is complete and reproduces the old behavior, and now I'm looking at the caching piece.
Because this is a small, knowledgeable, and helpful group, I hope there will be no objection if some of the questions that I ask don't pertain specifically to Lua. It's all part of a single project from my perspective.
Two issues that I'm seeing right off the bat: first, Apache's mod_cache has a "CacheEnable" directive with which you specify the URIs that will be cached, e.g.
CacheEnable disk /content
CacheEnable disk /etc
and so forth. Only URIs so named are considered for caching. It doesn't look like there's an equivalent invocation in ngx_proxy's cache directives. proxy_no_cache allows you to specify conditions under which a response will NOT be cached, but it's not clear to me if that can be leveraged to allow the equivalent behavior. Can it be? Or is there some other way to do it?
Second, mod_cache supplies response headers like "Age", "X-Cache", and "X-Cache-Detail" that provide information about the age and source of the response. Whether or not these are returned to the end user, they're invaluable (even necessary) in cache maintenance and troubleshooting. Is there any easy way to get these headers (or some equivalent) generated by nginx? Scripting something in Lua would be a perfectly fine solution though I have no idea where I would place the code, or how it would access the necessary information. I suppose that knowledge of the details of the cache implementation would be necessary at minimum, though if such details are not part of a guaranteed API then it would seem imprudent to write something that depended on them.