Forum: NGINX cache based on file size

0ccc1f19cf7452e62de98d4920144b37?d=identicon&s=25 Johns, Kevin (Guest)
on 2013-08-06 00:29
(Received via mailing list)
Hi,

In looking over Nginx configuration for the proxy module, I do not see
an easy way to influence what is cached based on object size. I have two
use cases of interest:
1. Store a small file in a particular zone (e.g., SSD), and

2. Have a large file bypass the cache (no-store large files)

Any insight on how best to accomplish this would be greatly appreciated.

Kevin
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-08-17 02:54
(Received via mailing list)
Hello!

On Mon, Aug 05, 2013 at 10:28:31PM +0000, Johns, Kevin wrote:

> Hi,
>
> In looking over Nginx configuration for the proxy module, I do not see an easy
way to influence what is cached based on object size. I have two use cases of
interest:
> 1. Store a small file in a particular zone (e.g., SSD), and
>
> 2. Have a large file bypass the cache (no-store large files)
>
> Any insight on how best to accomplish this would be greatly appreciated.

The proxy_no_cache with appropriate variables (e.g., map'ed or
produced with embedded perl from $upstream_http_content_length)
might be usable.

E.g. the following should disable caching of responses larger than
999 bytes or with content length not known:

    map $upstream_http_content_length $toolarge {
        default    1;
        ~^\d\d\d$  0;
    }

    proxy_no_cache $toolarge;

(Untested.)

See http://nginx.org/r/proxy_no_cache for details.

--
Maxim Dounin
http://nginx.org/en/donation.html
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.