]> BookStack Code Mirror - website/commitdiff
Added compression guidance for search DB file
authorDan Brown <redacted>
Sun, 28 Jan 2024 18:59:16 +0000 (18:59 +0000)
committerDan Brown <redacted>
Sun, 28 Jan 2024 18:59:16 +0000 (18:59 +0000)
.gitignore
package.json
readme.md

index 9b97e9691e1ab2c8a4b6594e3c0f2eba306b15f8..16123347bde8c3a3cdc992a66ba774708832d053 100644 (file)
@@ -4,4 +4,5 @@ node_modules
 .hugo_build.lock
 .DS_Store
 /search/data
-/static/search.db
\ No newline at end of file
+/static/search.db
+/static/search.db.*
\ No newline at end of file
index edd56e26e8c72052edf4c6025622aded55dd43b9..1e4a20e27be08582c48ef00232dc42390e6f9445 100644 (file)
     "build:hugo:prod": "hugo",
     "build:hugo:watch": "hugo serve -DF",
     "build:search": "./search/webidx.pl public ./static/search.db",
+    "build:search:compress": "brotli -fZk ./static/search.db && gzip -fk9 ./static/search.db",
     "build": "npm-run-all --sequential build:css:prod build:hugo:prod build:search",
     "serve": "npm-run-all build:hugo:watch",
     "dev": "npm-run-all --parallel build:hugo:watch build:css:watch",
     "deploy:server": "rsync -avx --delete --exclude '.git/' --exclude 'node_modules/' --exclude 'search/data/' ./ bs-site:/var/www/bookstackapp.com/",
-    "deploy": "npm-run-all --sequential build:css:prod build:hugo:prod build:search deploy:server",
+    "deploy": "npm-run-all --sequential build:css:prod build:hugo:prod build:search build:search:compress deploy:server",
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "author": "Dan Brown",
index 74fae27adc88a093a3e3ccabd0a4f3fece77881e..2195a549643fd3ed97862d94fbc89f22ef288d6b 100644 (file)
--- a/readme.md
+++ b/readme.md
@@ -33,8 +33,15 @@ The script to build the index is located at `search/webidx.pl`, and can be ran v
 npm run build:search
 ```
 
-Note: you may need to install some dependencies to run the script see the `search/webidx.pl` for more information.
+**Note:** you may need to install some dependencies to run the script see the `search/webidx.pl` for more information.
 
-The above command will build the sqlite index database to `static/search.db`, intended to be deployed to production. In production use, this should be served with compression active to significantly reduce transfer size.
+The above command will build the sqlite index database to `static/search.db`, intended to be deployed to production. There is also a `npm run build:search:compress` command to compress the database file using brotli and gzip (requires both to be installed). In production use, these compressed files should be deployed then served from their compressed state where possible. Here's relevant config for nginx:
+
+```nginx
+location ~* \.(db)$ {
+  brotli_static on;
+  gzip_static on;
+}
+```
 
 Much of the search UI handling logic can be found in our `themes/bookstack/static/js/scripts.js` file.
\ No newline at end of file