# cache condition variable set $usecache ""; if ($is_global_cache = 1) { set $usecache "${usecache}A"; } # main config without processing cache pages include bx/conf/bitrix_general.conf; location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; } location ~ "^/pagespeed_static/" { } location ~ "^/ngx_pagespeed_beacon$" { } # php file processing location ~ \.php$ { if (!-f $request_filename) { rewrite ^(.*)/index.php$ https://sochi-elite.com/$1/ redirect; } set $cache_file "bitrix/html_pages$general_key@$args.html"; # test file conditions if (-f "$docroot/bitrix/html_pages/.enabled") { set $usecache "${usecache}B"; } if (-f "$docroot/$cache_file") { set $usecache "${usecache}C"; } # create rewrite if cache-file exists if ($usecache = "ABC" ) { rewrite .* /$cache_file last; } fastcgi_pass_header Last-Modified; proxy_pass $proxyserver; } # directories page processing location ~ /$ { set $cache_file "bitrix/html_pages$general_key/index@$args.html"; # test file conditions if (-f "$docroot/bitrix/html_pages/.enabled") { set $usecache "${usecache}B"; } if (-f "$docroot/$cache_file") { set $usecache "${usecache}C"; } # create rewrite if cache-file exists if ($usecache = "ABC" ) { rewrite .* /$cache_file last; } proxy_pass $proxyserver; } # Redirect from pages without last slash #rewrite ^([^.\?]*[^/])$ $1/ permanent; # Main location location / { location ~* ^.+\.(jpg|jpeg|gif|png|svg|ico|webp|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|otf|ttf|woff|woff2|eot)$ { expires 30d; try_files $uri $uri/ @fallback; } proxy_pass $proxyserver; }