How can I have nginx return 304 Not Modified based on a Redis cache?
-
30-06-2021 - |
문제
I'm looking at setting up a Redis cache to speed up a Ruby on Rails application deployed with nginx. I want nginx to send a 304 Not Modified either based on a timestamp in the Redis db (e.g. last modified), or based on the existence of a key. The only thing I found so far is how to cache full pages in Redis, like the following example from the HttpRedis module:
server {
location / {
set $redis_key $uri;
redis_pass name:6379;
default_type text/html;
error_page 404 = /fallback;
}
location = /fallback {
proxy_pass backend;
}
}
Does anyone know if this is possible? Or would you recommend another way to send 304 responses without going to the Rails stack?
해결책
You should be able to do this with the HttpRedis2Module and the HttpLuaModule.
제휴하지 않습니다 StackOverflow