# What's the difference between proxy\_store and proxy\_cache?

**URL:** <https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827>\
**Category:** NGINX\
**Created:** [November 13, 2011, 4:11pm UTC](https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827 "2011-11-13T16:11:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [November 13, 2011, 4:11pm UTC](https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827/1 "2011-11-13T16:11:02Z")

</div>

From Nginx official site there are two method to store remote upstream  
on local file system, “proxy\_cache” and “proxy\_store”, the document  
describes clearly on how to configure, but still I have problem on the  
differences. Months ago I did some test over the both and found  
proxy\_cache owns far better performance, and I thought proxy\_cache is  
“cache in memory”, recently after diving into source code, I recognized  
both are file based, so i’m not sure if it could afford high connection  
where disk probably becomes the bottleneck.

Posted at Nginx Forum:

> **[what's the difference between proxy\_store and proxy\_cache?](https://forum.nginx.org/read.php?2,218263,218263#msg-218263)**
>
> From Nginx official site there are two method to store remote upstream on local file system, "proxy\_cache" and "proxy\_store", the document describes clearly on how to configure, but still I have problem on the differences. Months...

---

<div class="post-metadata">

**Author:** ![zhenwei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/bc8723/32.png) [@zhenwei](https://www.ruby-forum.com/u/zhenwei)\
**Post date:** [November 13, 2011, 6:04pm UTC](https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827/2 "2011-11-13T18:04:55Z")

</div>

Hello!

On Sun, Nov 13, 2011 at 10:10:29AM -0500, zhenwei wrote:

> From Nginx official site there are two method to store remote upstream  
> on local file system, “proxy\_cache” and “proxy\_store”, the document  
> describes clearly on how to configure, but still I have problem on the  
> differences. Months ago I did some test over the both and found  
> proxy\_cache owns far better performance, and I thought proxy\_cache is  
> “cache in memory”, recently after diving into source code, I recognized  
> both are file based, so i’m not sure if it could afford high connection  
> where disk probably becomes the bottleneck.

“proxy\_cache” is general-purpose cache with automatic lookups  
before proxy\_pass, expiration support and so on. It is usually  
what you need if you need caching capabilities.

“proxy\_store” is just a method to store proxied files on disk. It  
may be used to construct cache-like setups (usually involving  
try\_files and/or error\_page-based fallback), though it’s up to you  
to implement any required logic.

Maxim D.

---

<div class="post-metadata">

**Author:** ![zhenwei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/bc8723/32.png) [@zhenwei](https://www.ruby-forum.com/u/zhenwei)\
**Post date:** [November 13, 2011, 7:06pm UTC](https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827/3 "2011-11-13T19:06:55Z")

</div>

On Sunday 13 November 2011 19:10:29 zhenwei wrote:

> From Nginx official site there are two method to store remote upstream  
> on local file system, “proxy\_cache” and “proxy\_store”, the document  
> describes clearly on how to configure, but still I have problem on the  
> differences.

The “proxy\_store” just stores backend’s responses to a defined path.  
It’s totally  
up to you, what to do with these files after they were stored.

The “proxy\_cache” alone doesn’t do anything. But with other  
proxy\_cache\_\*  
directives, you can setup a file cache with key, life time, etc.

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![zhenwei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/bc8723/32.png) [@zhenwei](https://www.ruby-forum.com/u/zhenwei)\
**Post date:** [November 14, 2011, 2:38am UTC](https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827/4 "2011-11-14T02:38:21Z")

</div>

thanks, and how about the performance?

Posted at Nginx Forum:

> **[Re: what's the difference between proxy\_store and proxy\_cache?](https://forum.nginx.org/read.php?2,218263,218281#msg-218281)**
>
> From Nginx official site there are two method to store remote upstream on local file system, "proxy\_cache" and "proxy\_store", the document describes clearly on how to configure, but still I have problem on the differences. Months...

---

<div class="post-metadata">

**Author:** ![zhenwei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/bc8723/32.png) [@zhenwei](https://www.ruby-forum.com/u/zhenwei)\
**Post date:** [November 15, 2011, 6:38am UTC](https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827/5 "2011-11-15T06:38:20Z")

</div>

thanks for your advise, using pseudo disk via memory or memcached are  
good approaches.

Posted at Nginx Forum:

> **[Re: what's the difference between proxy\_store and proxy\_cache?](https://forum.nginx.org/read.php?2,218263,218355#msg-218355)**
>
> From Nginx official site there are two method to store remote upstream on local file system, "proxy\_cache" and "proxy\_store", the document describes clearly on how to configure, but still I have problem on the differences. Months...

---

<div class="post-metadata">

**Author:** ![zhenwei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/bc8723/32.png) [@zhenwei](https://www.ruby-forum.com/u/zhenwei)\
**Post date:** [November 16, 2011, 12:08am UTC](https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827/6 "2011-11-16T00:08:53Z")

</div>

On Mon, Nov 14, 2011 at 12:48 AM, Valentin V. Bartenev [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> you may  
> need to tune kernel disk cache or even consider to put nginx cache on  
> “/dev/shm”.

I wouldn’t recommened putting it in tmpfs. Just let the OS buffer cache  
keep it in RAM.

If you happen to have some SSD’s on the other hand…

–Brian

---

<div class="post-metadata">

**Author:** ![zhenwei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/bc8723/32.png) [@zhenwei](https://www.ruby-forum.com/u/zhenwei)\
**Post date:** [November 16, 2011, 9:40am UTC](https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827/7 "2011-11-16T09:40:54Z")

</div>

Quit agree with you that SSD seems the right way to get high random  
write/read performs well, especially we’re serving thousands of websites  
for each Nginx.

Posted at Nginx Forum:

> **[Re: what's the difference between proxy\_store and proxy\_cache?](https://forum.nginx.org/read.php?2,218263,218424#msg-218424)**
>
> From Nginx official site there are two method to store remote upstream on local file system, "proxy\_cache" and "proxy\_store", the document describes clearly on how to configure, but still I have problem on the differences. Months...

---

<div class="post-metadata">

**Author:** ![zhenwei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/bc8723/32.png) [@zhenwei](https://www.ruby-forum.com/u/zhenwei)\
**Post date:** [November 14, 2011, 6:49am UTC](https://www.ruby-forum.com/t/whats-the-difference-between-proxy-store-and-proxy-cache/213827/8 "2011-11-14T06:49:16Z")

</div>

On Monday 14 November 2011 05:37:58 zhenwei wrote:

> thanks, and how about the performance?

So, if you care about disk performance and have enough RAM, probably,  
you may  
need to tune kernel disk cache or even consider to put nginx cache on  
“/dev/shm”.

Also, you can use the memcached module for caching.

wbr, Valentin V. Bartenev
