From 03268a3228ce32b8e910a57deff12a0b603c1216 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 8 Jul 2021 22:11:22 +0200 Subject: [PATCH] Update NGINX cache headers for assets --- conf/nginx.conf | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b4994be..b18ebe0 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -20,14 +20,6 @@ location __PATH__/ { more_set_headers "X-Download-Options: noopen"; more_set_headers "X-Permitted-Cross-Domain-Policies: none"; - location ~* \.(jpg|jpeg|gif|css|png|js|ico|swf|mp3|pdf)$ { - # Le contenu statique, est signalé au navigateur comme étant - # à garder en cache une semaine. Si il y a un proxy sur la - # route, celui-ci est autorisé à faire une copie et à la - # cacher. - expires 1w; - more_set_headers "Cache-Control: public"; - } location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; @@ -40,6 +32,27 @@ location __PATH__/ { fastcgi_param SCRIPT_FILENAME $request_filename; } + location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { + expires 30d; + more_set_headers "Vary: Accept-Encoding"; + log_not_found off; + } + + location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff|woff2|svg)$ { + access_log off; + expires 30d; + more_set_headers "Cache-Control: public"; + + ## No need to bleed constant updates. Send the all shebang in one fell swoop. + tcp_nodelay off; + + ## Set the OS file cache. + open_file_cache max=3000 inactive=120s; + open_file_cache_valid 45s; + open_file_cache_min_uses 2; + open_file_cache_errors off; + } + ## Begin - Security # deny all direct access for these folders location ~* /(.git|cache|bin|logs|backups)/.*$ { return 403; }