Welcome! Log In Create A New Profile

Advanced

Re: Cache by mime type

Francis Daly
July 22, 2012 04:10AM
On Fri, Jul 20, 2012 at 02:45:44PM -0400, burn wrote:

Hi there,

> with "proxy_no_cache $no_proxy;", there are css files in cache again.

I think the issue is with using both proxy_no_cache and proxy_cache_bypass
with the same $no_proxy variable.

(I think there was a bug related to this in the past -- something about
if you didn't use them with the same variable, bad things could happen.)

proxy_cache_bypass takes effect before the upstream is
contacted, so at that point $no_proxy is set based on an empty
$upstream_http_content_type. Later on, when proxy_no_cache is considered,
$no_proxy already has a value so that is used.

The following config seems to work for me:

===
http {
map $upstream_http_content_type $no_proxy {
default proxy;
~*^image/ 0;
}
proxy_cache_path proxy_cache keys_zone=images:1m inactive=1m;

server {
location / {
proxy_pass http://127.0.0.1:10080/;
proxy_no_cache $no_proxy;
proxy_cache_bypass 0;
proxy_cache images;
}
}
}
===

I can run the two commands

curl -i http://localhost:8000/a.png
curl -i http://localhost:8000/a.txt

and I see exactly one file in my proxy_cache directory. (And the error
log says what is going on.)

And then I can run the commands again, and from the Expires header,
I can see that the txt file came from upstream, and the png file came
from cache.

(I use the proxy_cache_bypass line just to hush a warning (in 1.2.1). I
have *not* tested this for the partly-remembered bug mentioned above.)

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Cache by mime type

burn July 20, 2012 09:57AM

Re: Cache by mime type

Denis F. Latypoff July 20, 2012 10:04AM

Re: Cache by mime type

burn July 20, 2012 01:47PM

Re: Cache by mime type

Valentin V. Bartenev July 20, 2012 02:00PM

Re: Cache by mime type

burn July 20, 2012 02:23PM

Re: Cache by mime type

Valentin V. Bartenev July 20, 2012 02:32PM

Re: Cache by mime type

burn July 20, 2012 02:45PM

Re: Cache by mime type

Valentin V. Bartenev July 20, 2012 02:52PM

Re: Cache by mime type

burn July 20, 2012 03:05PM

Re: Cache by mime type

Francis Daly July 22, 2012 04:10AM

Re: Cache by mime type

burn July 22, 2012 05:27AM

Re: Cache by mime type

Francis Daly July 22, 2012 02:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 316
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready