Welcome! Log In Create A New Profile

Advanced

Problem with uwsgi_no_cache

August 13, 2015 12:06AM
Hi all -

I'm attempting to exclude application/json data from storing in nginx's cache. All other content types are OK to cache. I thought that the below config would work for me, but nginx is still caching everything that is proxying. What am I doing wrong?

## in http block ##
map $http_content_type $no_cache {
default 0;
"application/json" 1;
}


## in vhost block ##
location / {
uwsgi_cache www;
uwsgi_cache_valid 200 10m;
uwsgi_cache_methods GET HEAD;
uwsgi_cache_bypass $no_cache;
uwsgi_no_cache $no_cache;
add_header X-uWSGI-Cache $upstream_cache_status;
include uwsgi_params;
uwsgi_pass www;
}

I've tried a few other ways to set $no_cache to 1 for json content. Tried the following in both the server block and the location / block.
if ($http_content_type = "application/json") {
set $no_cache 1;
}

Here's my build:
nginx version: nginx/1.6.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_geoip_module --with-http_realip_module --with-http_stub_status_module --with-file-aio --with-ipv6 --without-http_ssi_module --without-http_split_clients_module --without-http_referer_module --without-http_scgi_module --without-http_browser_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --add-module=/home/makerpm/rpmbuild/BUILD/nginx-1.6.2/mod/ngx_http_redis-0.3.7 --add-module=/home/makerpm/rpmbuild/BUILD/nginx-1.6.2/mod/nginx-x-rid-header --add-module=/home/makerpm/rpmbuild/BUILD/nginx-1.6.2/mod/nginx-upload-module --add-module=/home/makerpm/rpmbuild/BUILD/nginx-1.6.2/mod/nginx-upload-progress-module-0.8.4 --add-module=/home/makerpm/rpmbuild/BUILD/nginx-1.6.2/mod/echo-nginx-module-0.57 --with-ld-opt=-luuid --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

Thanks for your help.
Subject Author Posted

Problem with uwsgi_no_cache

daveyfx August 13, 2015 12:06AM

Re: Problem with uwsgi_no_cache

Francis Daly August 13, 2015 03:56AM

Re: Problem with uwsgi_no_cache

daveyfx August 15, 2015 01:48PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 87
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready