Du kannst auch einfach den Upstream Server die Kompression überlassen und dann einfach die gezippten Inhalte cachen. Ich normalisiere dazu zuerst den encoding header damit ich maximal drei Varianten im Cache habe:
set $normal_encoding "";
# Normalize deflate encoding
if ($http_accept_encoding ~* deflate) {
set $normal_encoding "deflate";
}
# Normalize gzip encoding
if ($http_accept_encoding ~* gzip) {
set $normal_encoding "gzip";
}
# Normalize static assets
if ($request_uri ~* "\.(jpeg|jpg|png|gif|gz|tgz|bz2|tbz|zip|rar|7z|mp3|ogg|ico|swf|mp4|flv|mov|dmg|mkv)") {
set $normal_encoding "";
}
# Define the normalize header
proxy_set_header Accept-Encoding $normal_encoding;
proxy_cache_key $scheme$host$request_uri$normal_encoding;