Expires max does not work in nginx. There is a site (nginx + php-fpm + memcache), but for some reason caching does not work. developers.google.com says that static is not cached. Nginx config itself?

server { listen 80; listen [::]:80; server_name .example.com; return 301 https://example.com$request_uri; } server { fastcgi_pass_header Last-Modified; gzip on; gzip_comp_level 3; gzip_types application/x-javascript application/javascript text/css; pagespeed on; pagespeed RewriteLevel OptimizeForBandwidth; pagespeed FileCachePath /var/ngx_pagespeed_cache; pagespeed LoadFromFile "https://example.com" "/home/www/example.com/www/"; pagespeed FetchHttps enable; pagespeed EnableFilters collapse_whitespace,rewrite_css,rewrite_js,combine_css,combine_javascript,prioritize_critical_css,insert_dns_prefetch; pagespeed DisableFilters convert_to_webp_animated,convert_jpeg_to_webp,convert_to_webp_lossless,recompress_webp; pagespeed EnableFilters in_place_optimize_for_browser; pagespeed InPlaceResourceOptimization on; pagespeed EnableFilters extend_cache; pagespeed EnableCachePurge on; pagespeed ImplicitCacheTtlMs 1209600000; pagespeed ImagePreserveURLs on; keepalive_timeout 70; ssl_session_cache shared:SSL:10m; ssl_session_timeout 5m; ssl_stapling on; ssl_prefer_server_ciphers on; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "HIGH:!RC4:!aNULL:!MD5:!kEDH"; listen 443 ssl http2; server_name .example.com; charset off; access_log /var/log/nginx/example.com-access.log; error_log /var/log/nginx/example.com-error.log; set $root_path /home/www/example.com/www; root $root_path; set $php_sock unix:/var/run/php-fpm/php-fpm.sock; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; client_max_body_size 1024M; client_body_buffer_size 10M; client_body_timeout 60; send_timeout 60; index index.php; autoindex off; error_page 404 /404.php; if (!-e $request_filename) { rewrite ^(.*)$ /bitrix/urlrewrite.php last; } location ~ "\.pagespeed\.([az]\.)?[az]{2}\.[^.]{10}\.[^.]+" { expires 7d; } if ($host = 'www0.example.com') { return 301 https://example.com$request_uri; } location @bitrix { add_header Cache-Control "private, max-age=1209600"; fastcgi_pass $php_sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php; } location ~* /bitrix/admin.+\.php$ { pagespeed off; try_files $uri @bitrixadm; fastcgi_pass $php_sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_ADMIN_VALUE "max_execution_time = 1200"; fastcgi_read_timeout 1200; fastcgi_send_timeout 1200; include fastcgi_params; } location @bitrixadm { fastcgi_pass $php_sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/bitrix/admin/404.php; } location = /favicon.ico { log_not_found off; access_log off; expires 7d; } location = /robots.txt { allow all; log_not_found off; access_log off; } # ht(passwd|access) location ~* /\.ht { deny all; } # repositories location ~* /\.(svn|hg|git) { deny all; } # Player options, disable no-sniff location ~* ^/bitrix/components/bitrix/player/mediaplayer/player$ { add_header Access-Control-Allow-Origin *; } location ~* ^.+\.(jpg|jpeg|gif|png|svg|ttf|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar)$ { access_log /var/log/nginx/example.com-access.log; expires max; error_page 404 /404.html; try_files $uri /404.html; } location ~ \.php$ { pagespeed off; try_files $uri @bitrix; fastcgi_pass $php_sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 
  • one
    Did he accidentally give specific references to files that are not cached? - andreymal
  • All images from the site, css, js, etc. - perrfect
  • Show all the headers that come for the resource on which that tool swears. Particularly interested in Cache-Control and Set-Cookie - Total Pusher
  • Problem solved. Pagespeed was enabled for location, which was responsible for statics. Thanks a lot for your help. - perrfect

0