• # Configurer Nginx ?

    Posté par (site web personnel, Mastodon) . En réponse à l’entrée du suivi Ajouter un réglage de cache aux nouvelles polices. Évalué à 2 (+0/-0).

    Hello,

    Si je ne me trompe pas, c'est la configuration du serveur nginx qu'il faudrait ajuster.

    J'ai regardé le contenu du dossier /public/fonts et je dirai qu'il faudrait activer le cache du navigateur pour tous les fichiers présents (les extensions y présentes sont pour l'instant afm, otf, ttf, woff, woff2).

    Voici les résultats avec curl et différents fichiers (on voit bien que cache-control est présent pour une image et pour une police ttf, mais pas pour les nouvelles en woff et woff2):

    adrien@bureau-ado ~/code/linuxfr.org/public/fonts
     % curl -I https://linuxfr.org/images/markdown.png
    HTTP/2 200 
    server: nginx/1.10.3
    date: Thu, 19 Sep 2019 18:35:12 GMT
    content-type: image/png
    content-length: 298
    last-modified: Sat, 24 Feb 2018 14:16:08 GMT
    etag: "5a9173a8-12a"
    expires: Sun, 29 Sep 2019 18:35:12 GMT
    cache-control: max-age=864000
    x-content-type-options: nosniff
    accept-ranges: bytes
    adrien@bureau-ado ~/code/linuxfr.org/public/fonts
     % curl -I https://linuxfr.org/fonts/LinLibertine.ttf 
    HTTP/2 200 
    server: nginx/1.10.3
    date: Thu, 19 Sep 2019 18:36:20 GMT
    content-type: font/truetype
    content-length: 509248
    last-modified: Wed, 13 Jul 2011 12:40:26 GMT
    etag: "4e1d923a-7c540"
    expires: Sun, 29 Sep 2019 18:36:20 GMT
    cache-control: max-age=864000
    x-content-type-options: nosniff
    accept-ranges: bytes
    adrien@bureau-ado ~/code/linuxfr.org/public/fonts
     % curl -I https://linuxfr.org/fonts/Lato-Regular.woff
    HTTP/2 200 
    server: nginx/1.10.3
    date: Thu, 19 Sep 2019 18:35:37 GMT
    content-type: application/font-woff
    content-length: 309192
    last-modified: Sat, 24 Aug 2019 20:47:48 GMT
    etag: "5d61a274-4b7c8"
    x-content-type-options: nosniff
    accept-ranges: bytes
    adrien@bureau-ado ~/code/linuxfr.org/public/fonts
     % curl -I https://linuxfr.org/fonts/Lato-Regular.woff2
    HTTP/2 200 
    server: nginx/1.10.3
    date: Thu, 19 Sep 2019 18:36:26 GMT
    content-type: application/octet-stream
    content-length: 182708
    last-modified: Sat, 24 Aug 2019 20:47:48 GMT
    etag: "5d61a274-2c9b4"
    x-content-type-options: nosniff
    accept-ranges: bytes

    Je suis étonné que l'on ait mis que 86400 secondes, ça fait juste un jour de cache. Personnellement, surtout pour les polices, j'aurais mis quelque chose comme 1 semaine, car c'est vraiment rare de les changer.