Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit ccbc612

Browse files
committed
Fixed cache problems with index.html & __config.js.
1 parent 653c452 commit ccbc612

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/Handler/templates/nginx_default.conf.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@
232232
rewrite ^(.+)/+$ $1 permanent;
233233
rewrite ^(.+)/index.html$ $1 permanent;
234234

235+
location ~ index\.html {
236+
expires 30m;
237+
add_header "Cache-Control" "public, max-age=1800";
238+
try_files $uri =404;
239+
}
240+
241+
location ~ __config\.js {
242+
expires 30m;
243+
add_header "Cache-Control" "public, max-age=1800";
244+
try_files $uri =404;
245+
}
246+
235247
location ~* \.(webm|png|jpg|jpeg|gif|pdf|doc|docx|ico|zip|mp3|rar|exe|wmv|avi|ppt|pptx|mpg|mpeg|tif|wav|mov|psd|ai|xls|xlsx|mp4|m4a|swf|dat|dmg|iso|flv|m4v|torrent|ttf|woff|woff2|otf|svg|eot)$ {
236248
expires 1y;
237249
add_header "Cache-Control" "public, max-age=31536000";
@@ -244,10 +256,6 @@
244256
try_files $uri =404;
245257
}
246258

247-
<?php foreach($headers as $name => $value):?>
248-
add_header "<?=$name?>" "<?=addslashes($value)?>";
249-
<?php endforeach;?>
250-
251259
<?php if ($prerenderEnabled):?>
252260
location / {
253261
try_files $uri @prerender;
@@ -291,11 +299,24 @@
291299
}
292300

293301
if ($prerender = 0) {
302+
<?php foreach($headers as $name => $value):?>
303+
add_header "<?=$name?>" "<?=addslashes($value)?>";
304+
<?php endforeach;?>
305+
expires 30m;
306+
add_header "Cache-Control" "public, max-age=1800";
307+
294308
rewrite ^(.+)$ /index.html?$query_string break;
295309
}
296310
}
297311
<?php else:?>
298312
location / {
313+
<?php foreach($headers as $name => $value):?>
314+
add_header "<?=$name?>" "<?=addslashes($value)?>";
315+
<?php endforeach;?>
316+
317+
expires 30m;
318+
add_header "Cache-Control" "public, max-age=1800";
319+
299320
try_files $uri @rewrites;
300321
}
301322

0 commit comments

Comments
 (0)