nginx: tipo MIME per jpg e mp4 (la foto del palio e i video arrivavano come application/octet-stream), cache lunga anche per loro e per il favicon; test che ogni estensione servita abbia il suo tipo
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A1dxvtsZx8NE9fwjXUNDBr
This commit is contained in:
+3
-1
@@ -26,6 +26,8 @@ server {
|
|||||||
audio/mpeg mp3;
|
audio/mpeg mp3;
|
||||||
image/svg+xml svg;
|
image/svg+xml svg;
|
||||||
image/x-icon ico;
|
image/x-icon ico;
|
||||||
|
image/jpeg jpg jpeg;
|
||||||
|
video/mp4 mp4;
|
||||||
font/woff2 woff2;
|
font/woff2 woff2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +39,7 @@ server {
|
|||||||
location ~* \.(css|js|mjs|json)$ {
|
location ~* \.(css|js|mjs|json)$ {
|
||||||
add_header Cache-Control "no-cache";
|
add_header Cache-Control "no-cache";
|
||||||
}
|
}
|
||||||
location ~* \.(png|webp|mp3|woff2)$ {
|
location ~* \.(png|webp|jpg|mp3|mp4|woff2|ico)$ {
|
||||||
add_header Cache-Control $media_cache;
|
add_header Cache-Control $media_cache;
|
||||||
}
|
}
|
||||||
location = /index.html {
|
location = /index.html {
|
||||||
|
|||||||
@@ -619,6 +619,19 @@ test('ogni cartella di assets usata dal gioco finisce nell\'immagine Docker', as
|
|||||||
for (const t of Object.values(story.tutorials)) for (const f of [t.src, t.poster]) assert.ok(existsSync(new URL(f, root)), f);
|
for (const t of Object.values(story.tutorials)) for (const f of [t.src, t.poster]) assert.ok(existsSync(new URL(f, root)), f);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// La foto del palio e i video arrivavano al browser come application/octet-stream (26 ottobre): ogni estensione
|
||||||
|
// servita deve avere il suo tipo in nginx.conf, sennò nginx (con i soli tipi dichiarati) non sa cos'è.
|
||||||
|
test('ogni estensione dei file serviti ha il suo tipo MIME in nginx.conf', async () => {
|
||||||
|
const { readdirSync } = await import('node:fs');
|
||||||
|
const root = new URL('../', import.meta.url);
|
||||||
|
const types = readFileSync(new URL('nginx.conf', root), 'utf8').match(/types \{([^}]*)\}/)[1];
|
||||||
|
const known = new Set(types.split(';').flatMap(l => l.trim().split(/\s+/).slice(1)));
|
||||||
|
const dirs = readFileSync(new URL('Dockerfile', root), 'utf8').match(/^COPY (assets\/\S+|src)\s/gm).map(l => l.split(' ')[1]);
|
||||||
|
const ext = new Set(['html', 'css']);
|
||||||
|
for (const d of dirs) for (const f of readdirSync(new URL(d + '/', root), { recursive: true })) if (/\.\w+$/.test(f)) ext.add(f.split('.').pop());
|
||||||
|
assert.deepEqual([...ext].filter(e => !known.has(e) && e !== 'txt').sort(), [], 'estensioni senza tipo in nginx.conf');
|
||||||
|
});
|
||||||
|
|
||||||
test('i file che il Docker copia sono leggibili da tutti (nginx gira con un altro utente)', async () => {
|
test('i file che il Docker copia sono leggibili da tutti (nginx gira con un altro utente)', async () => {
|
||||||
const { readdirSync, statSync } = await import('node:fs');
|
const { readdirSync, statSync } = await import('node:fs');
|
||||||
const root = new URL('../', import.meta.url);
|
const root = new URL('../', import.meta.url);
|
||||||
|
|||||||
Reference in New Issue
Block a user