-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from akvo/issue/200-caching
[#200] Respond HTTP 204 when no more changes are available
- Loading branch information
Showing
11 changed files
with
183 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
version: "3" | ||
|
||
services: | ||
mainnetwork: | ||
secondnetwork: | ||
image: alpine:3.10 | ||
command: tail -f /dev/null | ||
ports: | ||
- 8082:8082 | ||
nginx-auth0: | ||
image: akvo/flow-api-auth0-proxy:latest | ||
network_mode: service:mainnetwork | ||
network_mode: service:secondnetwork | ||
environment: | ||
- FLOW_API_BACKEND_URL=http://localhost:3000 | ||
- OIDC_DISCOVERY_URL=https://akvotest.eu.auth0.com/.well-known/openid-configuration | ||
- OIDC_EXPECTED_ISSUER=https://akvotest.eu.auth0.com/ | ||
upstream: | ||
image: jmalloc/echo-server:latest | ||
network_mode: service:mainnetwork | ||
environment: | ||
- PORT=3000 | ||
image: akvo/flow-api-auth0-proxy:latest | ||
network_mode: service:secondnetwork | ||
entrypoint: ["/usr/local/openresty/bin/openresty", "-c", "/usr/local/src/nginx-test.conf", "-g", "daemon off;"] | ||
volumes: | ||
- ./:/usr/local/src:ro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
worker_processes 1; | ||
error_log logs/error.log; | ||
|
||
events { | ||
worker_connections 128; | ||
} | ||
|
||
http { | ||
|
||
server_tokens off; | ||
|
||
server { | ||
|
||
listen 3000; | ||
default_type application/json; | ||
|
||
location / { | ||
return 204; | ||
add_header Cache-Control max-age=120; | ||
} | ||
|
||
location /ok { | ||
return 200 '{}'; | ||
add_header Cache-Control no-cache; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
# Checking nginx caching | ||
|
||
docker-compose up -d | ||
|
||
./test.sh "http://localhost:8082/flow/ok" 2>&1 | grep 'X-Cache-Status: MISS' | ||
./test.sh "http://localhost:8082/flow/" 2>&1 | grep 'X-Cache-Status: MISS' | ||
./test.sh "http://localhost:8082/flow/" 2>&1 | grep 'X-Cache-Status: HIT' | ||
./test.sh "http://localhost:8082/flow/" 2>&1 | grep 'X-Cache-Status: HIT' | ||
|
||
docker-compose down -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
token=$(curl --silent \ | ||
--data "client_id=qsxNP3Nex0wncADQ9Re6Acz6Fa55SuU8" \ | ||
--data "username=${AUTH0_USER}" \ | ||
--data "password=${AUTH0_PASSWORD}" \ | ||
--data "grant_type=password" \ | ||
--data "scope=openid email" \ | ||
--url "https://akvotest.eu.auth0.com/oauth/token" \ | ||
| jq -M -r .id_token) | ||
|
||
URL="${1}" | ||
shift | ||
|
||
curl --verbose \ | ||
--header "Content-Type: application/json" \ | ||
--header "Accept: application/vnd.akvo.flow.v2+json" \ | ||
--header "Authorization: Bearer ${token}" \ | ||
--request GET \ | ||
"$@" \ | ||
--url "${URL}" | jq -M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters