Skip to content

Commit

Permalink
🔧 Add cache-control headers
Browse files Browse the repository at this point in the history
Check static resources for modifications after 1 hour.
Never cache API responses.

Why:
- We are not yet using content hashed static resources, so we need to
  tell the browser to refresh its cache occasionally. Currently the
  users need to do a force refresh after deployment.
  • Loading branch information
luontola committed Jul 30, 2023
1 parent 7668ed0 commit 326b37c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions web/docker/nginx-default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ server {
real_ip_recursive on;

location / {
expires 1h;
add_header Cache-Control "public";
root /usr/share/nginx/html;
try_files $uri /index.html;
}

location /api {
expires -1;
add_header Cache-Control "private";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down

0 comments on commit 326b37c

Please sign in to comment.