Skip to content

Commit d109007

Browse files
authored
Merge branch 'master' into dev/add-new-response-type
2 parents bb744ca + e2ef03b commit d109007

14 files changed

+832
-164
lines changed

.astylerc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# astylerc
2+
align-pointer=name
3+
align-reference=name
4+
break-after-logical
5+
#indent=spaces=2
6+
max-code-length=120
7+
style=google
8+
suffix=none
9+
10+
# Indent
11+
indent-preproc-block
12+
13+
# Padding
14+
pad-header
15+
unpad-paren
16+
17+
# Formatting:
18+
add-brackets
19+
#convert-tabs
20+
21+
# Output:
22+
formatted

.format.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
# Search in the script folder
4+
pushd "$(dirname $0)" >/dev/null
5+
CWD="$(pwd -P)"
6+
popd >/dev/null
7+
FILES='ngx_cache_purge_module.c'
8+
9+
# The file format in accordance with the style defined in .astylerc
10+
astyle -v --options='.astylerc' ${FILES} || (echo 'astyle failed'; exit 1);
11+
12+
# To correct this, the issuance dos2unix on each file
13+
# sometimes adds in Windows as a string-endins (\r\n).
14+
dos2unix --quiet ${FILES} || (echo 'dos2unix failed'; exit 2);

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.t linguist-language=Text

.travis.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
sudo: required
2+
os: linux
3+
dist: trusty
4+
language: c
5+
compiler:
6+
- gcc
7+
- clang
8+
cache:
9+
apt: true
10+
directories:
11+
- download-cache
12+
env:
13+
global:
14+
- JOBS=4
15+
- NGINX_VERSION=1.12.0
16+
- NGINX_PREFIX=/opt/nginx
17+
- OPENSSL_PREFIX=/opt/ssl
18+
- OPENSSL_LIB=$OPENSSL_PREFIX/lib
19+
- OPENSSL_INC=$OPENSSL_PREFIX/include
20+
- OPENSSL_VER=1.0.2k
21+
22+
before_install:
23+
- sudo apt-get install -qq -y cpanminus
24+
25+
install:
26+
- if [ ! -d /opt ]; then mkdir /opt; fi
27+
- if [ ! -d download-cache ]; then mkdir download-cache; fi
28+
- if [ ! -f download-cache/nginx-$NGINX_VERSION.tar.gz ]; then wget -O download-cache/nginx-$NGINX_VERSION.tar.gz http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz; fi
29+
- if [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -O download-cache/openssl-$OPENSSL_VER.tar.gz https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz; fi
30+
- git clone https://github.com/openresty/test-nginx.git
31+
32+
script:
33+
- cd test-nginx/ && sudo cpanm . && cd ..
34+
- tar zxf download-cache/openssl-$OPENSSL_VER.tar.gz
35+
- cd openssl-$OPENSSL_VER/
36+
- ./config shared --prefix=$OPENSSL_PREFIX -DPURIFY > build.log 2>&1 || (cat build.log && exit 1)
37+
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
38+
- sudo make PATH=$PATH install_sw > build.log 2>&1 || (cat build.log && exit 1)
39+
- cd ..
40+
- tar zxf download-cache/nginx-$NGINX_VERSION.tar.gz
41+
- cd nginx-$NGINX_VERSION/
42+
- ./configure --prefix=$NGINX_PREFIX --with-debug --add-module=$PWD/.. > build.log 2>&1 || (cat build.log && exit 1)
43+
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
44+
- sudo make install > build.log 2>&1 || (cat build.log && exit 1)
45+
- cd ..
46+
- export PATH=$NGINX_PREFIX/sbin:$PATH
47+
# - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
48+
- nginx -V
49+
- ldd `which nginx`
50+
- prove t

CHANGES

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
2017-02-21 VERSION 2.4.1
2+
* Fix compatibility with nginx-1.11.6+, Sułowicz Paweł
3+
4+
2016-11-20 VERSION 2.4
5+
* Fix compatibility with nginx-1.7.12+.
6+
* explain the purge logic
7+
* feat(purge all): Include option to purge all the cached files
8+
This option can be slow if a lot of content is cached, or if the
9+
storage used for the cache is slow. But you really should be using
10+
RAM as your cache storage.
11+
* feat(partial keys): Support partial keys to purge multiple keys.
12+
Put an '*' at the end of your purge cache URL.
13+
e.g:
14+
proxy_cache_key $scheme$host$uri$is_args$args$cookie_JSESSIONID;
15+
curl -X PURGE https://example.com/pass*
16+
This will remove every cached page whose key cache starting with:
17+
httpsexample.com/pass*
18+
Be careful not passing any value for the values after the $uri, or put
19+
it at the end of your cache key.
20+
* Convert a config file to build a dynamic module
21+
122
2014-12-23 VERSION 2.3
223
* Fix compatibility with nginx-1.7.9+.
324

README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
About
22
=====
33
`ngx_cache_purge` is `nginx` module which adds ability to purge content from
4-
`FastCGI`, `proxy`, `SCGI` and `uWSGI` caches.
4+
`FastCGI`, `proxy`, `SCGI` and `uWSGI` caches. A purge operation removes the
5+
content with the same cache key as the purge request has.
56

67

78
Sponsors
@@ -18,7 +19,7 @@ Configuration directives (same location syntax)
1819
===============================================
1920
fastcgi_cache_purge
2021
-------------------
21-
* **syntax**: `fastcgi_cache_purge on|off|<method> [from all|<ip> [.. <ip>]]`
22+
* **syntax**: `fastcgi_cache_purge on|off|<method> [purge_all] [from all|<ip> [.. <ip>]]`
2223
* **default**: `none`
2324
* **context**: `http`, `server`, `location`
2425

@@ -27,7 +28,7 @@ Allow purging of selected pages from `FastCGI`'s cache.
2728

2829
proxy_cache_purge
2930
-----------------
30-
* **syntax**: `proxy_cache_purge on|off|<method> [from all|<ip> [.. <ip>]]`
31+
* **syntax**: `proxy_cache_purge on|off|<method> [purge_all] [from all|<ip> [.. <ip>]]`
3132
* **default**: `none`
3233
* **context**: `http`, `server`, `location`
3334

@@ -36,7 +37,7 @@ Allow purging of selected pages from `proxy`'s cache.
3637

3738
scgi_cache_purge
3839
----------------
39-
* **syntax**: `scgi_cache_purge on|off|<method> [from all|<ip> [.. <ip>]]`
40+
* **syntax**: `scgi_cache_purge on|off|<method> [purge_all] [from all|<ip> [.. <ip>]]`
4041
* **default**: `none`
4142
* **context**: `http`, `server`, `location`
4243

@@ -45,7 +46,7 @@ Allow purging of selected pages from `SCGI`'s cache.
4546

4647
uwsgi_cache_purge
4748
-----------------
48-
* **syntax**: `uwsgi_cache_purge on|off|<method> [from all|<ip> [.. <ip>]]`
49+
* **syntax**: `uwsgi_cache_purge on|off|<method> [purge_all] [from all|<ip> [.. <ip>]]`
4950
* **default**: `none`
5051
* **context**: `http`, `server`, `location`
5152

@@ -101,6 +102,18 @@ cache_purge_response_type
101102
Sets a response type of purging result.
102103

103104

105+
106+
Partial Keys
107+
============
108+
Sometimes it's not possible to pass the exact key cache to purge a page. For example; when the content of a cookie or the params are part of the key.
109+
You can specify a partial key adding an asterisk at the end of the URL.
110+
111+
curl -X PURGE /page*
112+
113+
The asterisk must be the last character of the key, so you **must** put the $uri variable at the end.
114+
115+
116+
104117
Sample configuration (same location syntax)
105118
===========================================
106119
http {
@@ -117,6 +130,22 @@ Sample configuration (same location syntax)
117130
}
118131

119132

133+
Sample configuration (same location syntax - purge all cached files)
134+
====================================================================
135+
http {
136+
proxy_cache_path /tmp/cache keys_zone=tmpcache:10m;
137+
138+
server {
139+
location / {
140+
proxy_pass http://127.0.0.1:8000;
141+
proxy_cache tmpcache;
142+
proxy_cache_key $uri$is_args$args;
143+
proxy_cache_purge PURGE purge_all from 127.0.0.1;
144+
}
145+
}
146+
}
147+
148+
120149
Sample configuration (separate location syntax)
121150
===============================================
122151
http {

config

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ if [ "$HTTP_UWSGI" = "YES" ]; then
1515
fi
1616

1717
ngx_addon_name=ngx_http_cache_purge_module
18-
HTTP_MODULES="$HTTP_MODULES ngx_http_cache_purge_module"
19-
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_cache_purge_module.c"
18+
CACHE_PURGE_SRCS="$ngx_addon_dir/ngx_cache_purge_module.c"
19+
20+
if [ -n "$ngx_module_link" ]; then
21+
ngx_module_type=HTTP
22+
ngx_module_name="$ngx_addon_name"
23+
ngx_module_srcs="$CACHE_PURGE_SRCS"
24+
25+
. auto/module
26+
else
27+
HTTP_MODULES="$HTTP_MODULES $ngx_addon_name"
28+
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $CACHE_PURGE_SRCS"
29+
fi
2030

2131
have=NGX_CACHE_PURGE_MODULE . auto/have

0 commit comments

Comments
 (0)