-
Notifications
You must be signed in to change notification settings - Fork 13
133 lines (120 loc) · 4.06 KB
/
cache-control.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Cache-Control Test
on:
push:
branches:
- feature/proxy-cache
workflow_dispatch:
jobs:
test-cache-control:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create configuration files
run: |
cat <<EOF > install/docker/config/nginx/test_cache.conf
server {
listen 8092;
location / {
default_type text/plain;
content_by_lua_block {
local args = ngx.req.get_uri_args()
local cache_control = args["cache_control"]
if cache_control then
ngx.header["Cache-Control"] = cache_control
ngx.say("Cache-Control set to: ", cache_control)
else
ngx.say("Cache-Control not specified. Use ?cache_control=<value> to set one.")
end
}
}
}
EOF
cat <<EOF > install/docker/router.yml
services:
onlyoffice-router:
image: openresty/openresty:latest
container_name: onlyoffice-router
restart: always
ports:
- "8092:8092"
volumes:
- ./config/nginx/test_cache.conf:/etc/nginx/conf.d/default.conf
networks:
default:
name: \${NETWORK_NAME}
external: true
EOF
- name: Run Docker containers and script
run: |
docker network create onlyoffice
docker-compose -f install/docker/proxy.yml up -d
docker-compose -f install/docker/router.yml up -d
- name: Wait for containers to become ready
run: |
echo "Waiting for containers to become ready..."
bash -c 'until curl -s http://localhost:80; do sleep 1; done'
bash -c 'until curl -s http://localhost:8092; do sleep 1; done'
- name: Execute testing script
run: |
CACHE_CONTROLS=(
"no-cache"
"no-store"
"public"
"private"
"max-age=0"
"max-age=60"
"s-maxage=60"
"max-age=3600"
"must-revalidate"
"proxy-revalidate"
"max-age=120,must-revalidate"
"no-cache,no-store"
"public,max-age=60"
"private,max-age=120"
"immutable"
"public,s-maxage=60,max-age=30"
"no-cache,max-age=0"
"private,no-cache"
"public,no-transform"
"no-store,must-revalidate,max-age=0"
"public,max-age=0"
"private,s-maxage=60"
"no-cache,max-age=30"
"immutable,max-age=3600"
"no-store,s-maxage=120"
"max-age=300,must-revalidate"
"proxy-revalidate,max-age=600"
"no-transform,max-age=900"
"public,no-cache"
"private,no-store"
"must-revalidate,max-age=1200"
"proxy-revalidate,s-maxage=150"
"no-cache,no-store,max-age=0"
"public,immutable,max-age=31536000"
"private,max-age=60,must-revalidate"
"public,max-age=120,proxy-revalidate"
"no-store,no-cache,must-revalidate,max-age=0"
"private,immutable,s-maxage=43200"
"public,no-transform,s-maxage=60,max-age=30"
"max-age=60,no-transform,must-revalidate"
)
HITS=()
MISSES=()
for CC in "${CACHE_CONTROLS[@]}"; do
curl -s -I "http://localhost/?cache_control=${CC}" > /dev/null
if $(curl -s -I "http://localhost/?cache_control=${CC}" | grep "X-Cache-Status" | grep -q "HIT"); then
HITS+=("$CC")
else
MISSES+=("$CC")
fi
done
echo "Cache-Control directives that resulted in a HIT:"
for HIT in "${HITS[@]}"; do
echo "- $HIT"
done
echo "-----------------------------------"
echo "Cache-Control directives that resulted in a MISS:"
for MISS in "${MISSES[@]}"; do
echo "- $MISS"
done