Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Nginx Caching - Return 301 Redirect if file size > 2MB

$
0
0
Hello, everyone!

I have a rule in place that will proxy and cache a bunch of file extensions:

######

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
proxy_pass http://{backend_IPs_pool};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache STATIC;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;
}

######

I need the proxy server to bypass the cache in case the file size is larger than 2MB. I believe the best way to achieve that would be by forwarding the request to the upstream through a 301 redirect so that I can save the extremely expensive bandwidth on the proxy server.

Any ideas?

Thank you very much!

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>