# Proxy\_cache or direct static files?

**URL:** <https://www.ruby-forum.com/t/proxy-cache-or-direct-static-files/238067>\
**Category:** NGINX\
**Created:** [December 15, 2013, 11:02am UTC](https://www.ruby-forum.com/t/proxy-cache-or-direct-static-files/238067 "2013-12-15T11:02:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [December 15, 2013, 11:02am UTC](https://www.ruby-forum.com/t/proxy-cache-or-direct-static-files/238067/1 "2013-12-15T11:02:10Z")

</div>

Hello,

I don’t quite understand what I could get from caching with proxy\_cache  
vs  
serving static files directly.

Everywhere people tend to say that it is better to cache, but isn’t  
caching  
the same as serving directly from static file ?

Say that I serve home.html from a plain static html file, would I get  
any  
benefit to use reverse proxy + cache to serve it ?

Thanks,

Posted at Nginx Forum:

> **[Proxy\_cache or direct static files ?](https://forum.nginx.org/read.php?2,245544,245544#msg-245544)**
>
> Hello, I don't quite understand what I could get from caching with proxy\_cache vs serving static files directly. Everywhere people tend to say that it is better to cache, but isn't caching the same as serving directly from static file ? Say that I...

---

<div class="post-metadata">

**Author:** ![larry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@larry](https://www.ruby-forum.com/u/larry)\
**Post date:** [December 16, 2013, 11:48am UTC](https://www.ruby-forum.com/t/proxy-cache-or-direct-static-files/238067/2 "2013-12-16T11:48:26Z")

</div>

Did i understand something wrong ?

Thanks

Posted at Nginx Forum:

> **[Re: Proxy\_cache or direct static files ?](https://forum.nginx.org/read.php?2,245544,245552#msg-245552)**
>
> Hello, I don't quite understand what I could get from caching with proxy\_cache vs serving static files directly. Everywhere people tend to say that it is better to cache, but isn't caching the same as serving directly from static file ? Say that I...

---

<div class="post-metadata">

**Author:** ![larry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@larry](https://www.ruby-forum.com/u/larry)\
**Post date:** [December 16, 2013, 12:42pm UTC](https://www.ruby-forum.com/t/proxy-cache-or-direct-static-files/238067/3 "2013-12-16T12:42:11Z")

</div>

Hello!

On Sun, Dec 15, 2013 at 05:01:25AM -0500, Larry wrote:

> Hello,
> 
> I don’t quite understand what I could get from caching with proxy\_cache vs  
> serving static files directly.
> 
> Everywhere people tend to say that it is better to cache, but isn’t caching  
> the same as serving directly from static file ?
> 
> Say that I serve home.html from a plain static html file, would I get any  
> benefit to use reverse proxy + cache to serve it ?

Caching is useful when you have some resource which is costly to  
generate (e.g., dynamic pages or remote resources). If you are  
serving static files which are already present on the same server,  
in most cases there are no reasons to use cache. In some rare  
cases it may be useful though, e.g., if you have some faster  
storage for cache.

–  
Maxim D.  
[http://nginx.org/](http://nginx.org/)

---

<div class="post-metadata">

**Author:** ![larry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@larry](https://www.ruby-forum.com/u/larry)\
**Post date:** [December 16, 2013, 12:43pm UTC](https://www.ruby-forum.com/t/proxy-cache-or-direct-static-files/238067/4 "2013-12-16T12:43:56Z")

</div>

On 16 December 2013 10:47, Larry [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote

> Did i understand something wrong ?

Yes.

Proxy cache is for storing the response of an upstream HTTP server  
whose requests you’re proxying, so that you don’t have to ask the  
potentially slow(er) upstream server the next time an identical  
request comes in.

Serving static files from local disk is, well, for on-disk local assets.

They’re different concepts. Don’t confuse them. Just recognise  
whichever one you’re doing, and use the appropriate technique.

---

<div class="post-metadata">

**Author:** ![larry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@larry](https://www.ruby-forum.com/u/larry)\
**Post date:** [December 19, 2013, 3:49pm UTC](https://www.ruby-forum.com/t/proxy-cache-or-direct-static-files/238067/5 "2013-12-19T15:49:36Z")

</div>

Ok,

Now I get it right 🙂

@Maxim : when you say faster memory storage, doesn’t nginx get the  
result  
cached by the os itself ? And so in the ram ?

What could be faster than that ?

Thanks

Posted at Nginx Forum:

> **[Re: Proxy\_cache or direct static files ?](https://forum.nginx.org/read.php?2,245544,245721#msg-245721)**
>
> Hello, I don't quite understand what I could get from caching with proxy\_cache vs serving static files directly. Everywhere people tend to say that it is better to cache, but isn't caching the same as serving directly from static file ? Say that I...

---

<div class="post-metadata">

**Author:** ![larry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@larry](https://www.ruby-forum.com/u/larry)\
**Post date:** [December 19, 2013, 4:21pm UTC](https://www.ruby-forum.com/t/proxy-cache-or-direct-static-files/238067/6 "2013-12-19T16:21:10Z")

</div>

Hello!

On Thu, Dec 19, 2013 at 09:48:45AM -0500, Larry wrote:

> Ok,
> 
> Now I get it right 🙂
> 
> @Maxim : when you say faster memory storage, doesn’t nginx get the result  
> cached by the os itself ? And so in the ram ?
> 
> What could be faster than that ?

Consider you have 100T of data on rotating disks, 32G of memory,  
and 256G of SSD available. In such a case, using SSD for a cache  
may be beneficial - not because something is faster than RAM, but  
because you don’t have enough RAM to cache everything.

–  
Maxim D.  
[http://nginx.org/](http://nginx.org/)

---

<div class="post-metadata">

**Author:** ![larry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@larry](https://www.ruby-forum.com/u/larry)\
**Post date:** [December 21, 2013, 8:00am UTC](https://www.ruby-forum.com/t/proxy-cache-or-direct-static-files/238067/7 "2013-12-21T08:00:07Z")

</div>

Makes sense

Thanks

Posted at Nginx Forum:

> **[Re: Proxy\_cache or direct static files ?](https://forum.nginx.org/read.php?2,245544,245752#msg-245752)**
>
> Hello, I don't quite understand what I could get from caching with proxy\_cache vs serving static files directly. Everywhere people tend to say that it is better to cache, but isn't caching the same as serving directly from static file ? Say that I...
