1
Fork 0

e11sync-static: fix caching

This commit is contained in:
Motiejus Jakštys 2024-01-26 13:48:24 +02:00
parent 7cec799cfa
commit d54da85c56
2 changed files with 10 additions and 3 deletions

View File

@ -6,7 +6,7 @@
writeTextFile {
name = "e11sync-caddyfile";
text = ''
header /static/CACHE/* Cache-Control "public, max-age=31536000, immutable"
header /static/* Cache-Control "public, max-age=31536000, immutable"
route /static/* {
uri strip_prefix /static

View File

@ -6,6 +6,7 @@
brotli,
findutils,
dart-sass,
jq,
}: let
self = stdenv.mkDerivation {
name = "e11sync-static";
@ -18,14 +19,20 @@
];
patchPhase = ''patchShebangs --build app/manage.py'';
buildPhase = ''
export E11SYNC_DEBUG=
make -C static style.css
app/manage.py collectstatic
# remove unversioned files
(cd app/_static;
${jq}/bin/jq -r '.paths | keys[]' staticfiles.json | \
xargs rm
)
find app/_static \
-name '*.css' -or \
-name '*.js' -or \
-name '*.svg' | \
-name '*.svg' -or \
-name '*.txt' | \
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
'';