Hi,
I was wondering if there was a cleaner Lua way to check immediately whether a particular URI was present the Nginx cache (specifically when using proxy_pass and proxy_cache) without actually making a request that would subsequently causing Nginx to populate it (e.g when trying to use the $upstream_cache_status). So far I can think of a few of approaches (but most suffer from lack of access to cache 'shared memory zone' info):
1) Use the cache key and generate the corresponding md5 hash in conjunction with the levels setting and directly check for the presence of the actual cache file in the cache directory - but this can't check the cache 'shared memory zone' info...so it may be out of sync with the actual Nginx cache state.
2) Use some kind of FFI call to directly query the Nginx cache API? (Has anyone done this?)
3) Creating a separate lua_shared_dict cache key in Lua for the URI - again it may not be in sync with cache's 'shared memory zone' info
4) Using the [defunct?] ngx-lua-upstream-cache-module module - this isn't so useful as it requires additional compilation/linking to Openresty
Ideally it would be great if there was a way to serve an incoming request from the Nginx cache if present or else do something in Lua.
Any suggestions/ideas welcome.
Piers