Exclude specific location from cache

Dewangga Bachrul Alam dewanggaba at xtremenitro.org
Thu Dec 24 09:24:12 UTC 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Sorry I forgot something, I'm using Nginx Plus R7.

nginx version: nginx/1.9.4 (nginx-plus-http2-r7-p1)
built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --build=nginx-plus-http2-r7-p1
- --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_v2_module
- --with-http_realip_module --with-http_addition_module
- --with-http_sub_module --with-http_dav_module --with-http_flv_module
- --with-http_mp4_module --with-http_gzip_static_module
- --with-http_gunzip_module --with-http_random_index_module
- --with-http_secure_link_module --with-http_stub_status_module
- --with-http_auth_request_module --with-mail --with-mail_ssl_module
- --with-threads --with-file-aio --with-ipv6 --with-stream
- --with-stream_ssl_module --with-http_f4f_module
- --with-http_session_log_module --with-http_hls_module
- --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
- -fstack-protector-strong --param=ssp-buffer-size=4
- -grecord-gcc-switches -m64 -mtune=generic'


On 12/24/2015 04:01 PM, Dewangga Bachrul Alam wrote:
> Hello!
> 
> Currently my configuration looks like this :
> 
> map $request_method $purge_method { PURGE 1; default 0; }
> 
> map $arg_geoloc $bypass { default 1; 1       0; }
> 
> # Exclude from cache # Expected URL http://domain.tld/ location = /
> { proxy_pass [..]; proxy_no_cache $bypass; proxy_cache_bypass
> $bypass; }
> 
> # Expected URL http://domain.tld/indeks/* # Expected URL
> http://domain.tld/kanal/* location ~ ^/(indeks|kanal)/ { proxy_pass
> [..]; proxy_no_cache $bypass; proxy_cache_bypass $bypass; }
> 
> # The rest are cached # Expected URL http://domain.tld/* (except
> the condition above) location / { proxy_pass [..]; proxy_cache
> my_cache; proxy_cache_purge       $purge_method; 
> proxy_cache_use_stale error timeout updating http_500 http_502 
> http_503 http_504; proxy_cache_valid 200 206 302 1h; 
> proxy_cache_valid any 3s; proxy_cache_lock on; 
> proxy_cache_revalidate on; proxy_cache_min_uses 10; }
> 
> My goal is, exclude the homepage, indeks and kanal pages, then
> cache the rest URL. Am I right with the configuration above?
> 
> Any help and advice are appreciated.
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJWe7m5AAoJEOV/0iCgKM1w42YQAIor0QWCF6yiqM0Ea+Ek+LnU
BJUMe+bJecJsStV++S6QnfpaqcvDBr4hl5NzsgdG1eY3BX2rKWx6AGMMJAlrgTuI
eHSeb3Fvd7OBkGp0hr6+wkeeMfn/KsFL3kPwqqfS7KDAsH2z43Jzznj5XttFH+Vo
GcGHMDqUtLURWxepXpfFAWsfHWmv4MbD1pGksbLlBnYMS8wkIgn0+mUlTSkYTldi
SxWwtkRLDA2mQhw8vE99o3nmgpv26qTXJTX8+DgHOx3yhX364Ka8i4egSgrQO81a
oYT6HP07R6o63CdjY8b7aShG7IwtOMYf7NM3bn7eu/9dn8t/y0vzfRRtN9ZtHnsp
ejp8BiFkodOMclW27CQ2oMWIv7IJJuVV3q5IyVNFARYK1sGKM3GKWyiZLy+rLVGU
K3SUnvPO9dH1d9UyzvnzLf/bS7EwXhdPnPkOIiX1xdN/RJls8XJogLBNxqaF/mHo
ih0xTDvpLO6sYcEmSjECy1WZDoxmFbiL5pVi0sWD5unFoUuUk+XoFbrJCzi3tMTv
CWUZt1WbOxV3sgQRHbnH6ZyzYOFaAaLPBYgCWJR8uRXGTtn2ybSYhFLtkNxsjxgO
RqRYBptVbdRPbHb5AAU9YOh8Vi2ktMZCoX016pdLXvnm0l/ikYrf903e9wMO7DSB
9mCYvrrRShJqCRifm7GT
=z8GZ
-----END PGP SIGNATURE-----



More information about the nginx mailing list