nginx : fastcgi_cache
On ne touche qu’à la configuration de nginx. La doc : https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html block http Dans le block http on a : fastcgi_cache_path /home/cache levels=1:2 keys_zone=MyCMS:100m max_size=10g inactive=60m use_temp_path=off; fastcgi_cache_key "$scheme$request_method$host$request_uri"; block server Un exemple pour wordpress : server { listen 80; server_name mycms.net; root /var/www/mycms; set $skip_cache 0; if ($request_method = POST) { set $skip_cache 1; } if ($query_string != "") { set $skip_cache 1; } if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-..php|^/feed/|/tag/./feed/|/.sitemap..(xml|xsl)") { set $skip_cache 1; } if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $skip_cache 1; } location ~ \.php$ { fastcgi_cache MyCMS; fastcgi_cache_valid 200 301 302 60m; fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503; fastcgi_cache_min_uses 1; # fastcgi_cache_lock on; fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; add_header X-FastCGI-Cache $upstream_cache_status; try_files $uri $uri/ /index.php; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/run/php/php8.1-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; add_header X-Frame-Options "SAMEORIGIN"; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; } location / { index index.php; try_files $uri $uri/ /index.php?$args; } location ~* \.(js|png|jpg|jpeg|gif|ico|css|woff2|svg|ttf|woff)$ { access_log off;expires 365d;log_not_found off; } location ~ /\.well-known/acme-challenge { allow all;} location ~* /(uploads|files)/.*\.php$ { deny all; } location = /favicon.ico { log_not_found off; access_log off; } location ~ /\. { deny all; } location = /robots.txt { allow all; log_not_found off; access_log off; } }