From d5df65163ac9e5303c9ed932e1e57b9cc5057db7 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 2 Nov 2022 22:05:39 +0200 Subject: [PATCH] fix: use immutable cache header --- README.md | 17 +++++++++++++++-- src/config/app.ts | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 91a7d99..a7b8b23 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,11 @@ Options that can be changed with environment variables and their default values - `ENABLE_SEARCH_ENGINE=true`: enables `/search` route. Requires `ENABLE_ICON_LISTS` to be enabled. - `ALLOW_FILTER_ICONS_BY_STYLE=true`: allows searching for icons based on fill or stroke, such as adding `style=fill` to search query. This feature uses a bit of memory, so it can be disabled. Requires `ENABLE_SEARCH_ENGINE` to be enabled. -### Update +### Updating icons -In addition to updating icon sets when server starts, API can update icon sets without restarting server. +Icons are automatically updated when server starts. + +In addition to that, API can update icon sets without restarting server. To enable automatic update, you must set `APP_UPDATE_SECRET` environment variable. Without it, update will not work. @@ -77,6 +79,17 @@ Update will not be triggered immediately, it will be ran after `UPDATE_THROTTLE` If update is triggered while update process is already running (as in, source was checked for update, but download is still in progress), another update check will be ran after currently running update ends. +Response to `/update` route is always the same, regardless of outcome. This is done to make it impossible to try to guess key/value pair or even see if route is enabled. To see actual result, you need to check console. Successful request and update process will be logged. + +### HTTP headers + +By default, server sends the following HTTP headers: + +- Various CORS headers, allowing access from anywhere. +- Cache headers to cache responses for 604800 seconds (7 days). + +To change headers, edit `header` property in `src/config/app.ts`, then rebuild script. + ## Node vs PHP Previous version of API was also available as PHP script. This has been discontinued. Node app performs much faster, can handle thousands of queries per second and uses less memory. diff --git a/src/config/app.ts b/src/config/app.ts index fedba49..7ec0140 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -22,7 +22,7 @@ export const appConfig: AppConfig = { 'Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Accept-Encoding', 'Access-Control-Max-Age: 86400', 'Cross-Origin-Resource-Policy: cross-origin', - 'Cache-Control: public, max-age=604800, min-refresh=604800', + 'Cache-Control: public, max-age=604800, min-refresh=604800, immutable', ], // Host and port for server