Skip to content

Commit

Permalink
nginx: add Cache-Control header (#791)
Browse files Browse the repository at this point in the history
* nginx: add Cache-Control header

* set cache control only for index.html

* set max-age

* reduce default cache age

* bump cache age to 1 year

* no-cache for config.js
  • Loading branch information
deer-wmde authored Mar 14, 2024
1 parent 73ade83 commit 4b353d9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ server {
location / {
root /usr/share/nginx/html;
try_files $uri /index.html;

# cache everything for 1 year
add_header 'Cache-Control' 'max-age: 31536000, immutable' always;
}

# do not cache index.html or config.js - https://phabricator.wikimedia.org/T331423
location ~ /(index.html|config.js) {
add_header 'Cache-Control' 'no-cache' always;
}

# deny access to .htaccess files, if Apache's document root concurs with nginx's one
Expand Down

0 comments on commit 4b353d9

Please sign in to comment.