Proxy_cache or direct static files?

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:

Did i understand something wrong ?

Thanks

Posted at Nginx Forum:

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/

On 16 December 2013 10:47, Larry [email protected] 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.

Ok,

Now I get it right :slight_smile:

@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:

Hello!

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

Ok,

Now I get it right :slight_smile:

@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/

Makes sense

Thanks

Posted at Nginx Forum: