# Proxy\_cache\_path max\_size doesn't work

**URL:** <https://www.ruby-forum.com/t/proxy-cache-path-max-size-doesnt-work/244224>\
**Category:** NGINX\
**Created:** [March 8, 2016, 1:23pm UTC](https://www.ruby-forum.com/t/proxy-cache-path-max-size-doesnt-work/244224 "2016-03-08T13:23:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [March 8, 2016, 1:23pm UTC](https://www.ruby-forum.com/t/proxy-cache-path-max-size-doesnt-work/244224/1 "2016-03-08T13:23:11Z")

</div>

Hi,

I’m using nginx as a reverse proxy with caching on a ramdisk  
/var/cache/nginx is a tmpfs of the size 1800m.  
And this is my proxy\_cache\_path line in nginx:

proxy\_cache\_path /var/cache/nginx levels=1:2 use\_temp\_path=off  
keys\_zone=default:50m inactive=120m max\_size=1500m;

This is the error message when the ramdisk is filled.

[crit] 1460#0: \*14844194 pwritev()  
“/var/cache/nginx/temp/3/12/0001578123”  
failed (28: No space left on device) while reading upstream, client:  
XXX,  
server: , request: “GET /xxx.jpg HTTP/1.1”, upstream: "  
[http://127.0.0.1:81/xxx.jpg](http://127.0.0.1:81/xxx.jpg)", host: “[xxx.com](http://xxx.com)”, referrer:  
“[http://xxx.com/](http://xxx.com/)”

I see two problems here.

1. Why didn’t max\_size work and clear the space in the tmpfs mount when  
it  
got past 1500m?
2. Why doesn’t nginx just bypass the cache and serve from upstrean when  
the  
mount is full instead of hard failing?

And what solutions do I have?  
Do I increase the ramdisk/tmpfs size?  
Do I decrease the max\_size?  
Should I run a external cronjob that restarts nginx when the ramdisk is  
more than 1500MB?

Or is nginx proxy\_cache\_path broken and do I need to change to another  
solution like squid or varnish?
