desbouis / nginx-redis-proxy

Nginx as reverse proxy using redis as cache engine
105 stars 29 forks source link

Cache headers with body #5

Closed desbouis closed 12 years ago

desbouis commented 12 years ago

Now, only the body of a web object is cached in redis. Better is to store http headers with the body : like that, sometimes I want that my json file has utf-8 encoding, sometimes I want my html page has iso-8859-1 encoding. The backend is managing the good headers, the backend is always serving good headers. In fact, an web object is a body with its http headers.

desbouis commented 12 years ago

I will use hash type to store headers and body in redis like this :

HMSET my_uri headers my_headers body my_body

But there is not a command to set a TTL to a hash type like SETEX for a string type. So I will use two commands in a transaction to do that :

MULTI HMSET my_uri headers my_headers body my_body EXPIRE my_uri my_ttl EXEC