LINUX.ORG.RU
ФорумAdmin

Не могу отключить кэширование страницы в Wordpress

 , ,


0

2

Всем, привет! Не могу отключить кэширование страницы в Wordpress. Я конфижу Nginx мой ключ кеша

fastcgi_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri";
fastcgi_cache_use_stale error timeout updating invalid_header http_500;

set $no_cache 0;

Задача: на некоторых страницах вырубить кэш. Делаю такое:

if ($request_uri ~* "/custom-order/|/complete-order/") {
set $no_cache 1;
}

Не работает. Что не так?

Ответ на: комментарий от tfeartx

Это шаблонизатор. В нем правлю так как стоит ISPManager

gLObal restrictions configuration file.

location = /favicon.ico {
        log_not_found off;
        access_log off;
}

location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
}

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
        deny all;
}

# Deny access to any files with a .php extension in the uploads directory for the single site
location ~ ^/wp-content/uploads/.*\.php$ {
        deny all;
}

{% if $REDIRECT_TO_APACHE != on and $SRV_CACHE == on %} location ~* .(?:jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ { add_header Cache-Control public; log_not_found off; expires [% $EXPIRES_VALUE %]; }

location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
        add_header Cache-Control public;
        add_header Access-Control-Allow-Origin *;
        log_not_found off;
        expires [% $EXPIRES_VALUE %];
}

{% else %} location ~* .(?:jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ { add_header Cache-Control public; log_not_found off; }

location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
        add_header Cache-Control public;
        add_header Access-Control-Allow-Origin *;
        log_not_found off;
}

{% endif %} {% endif %}

{% if $REDIRECT_TO_PHPFPM == on %} {% if $REDIRECT_TO_APACHE != on and $SRV_CACHE == on %} #fastcgi_cache start

etag on;
if_modified_since before;

fastcgi_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri";
fastcgi_cache_use_stale error timeout updating invalid_header http_500;

set $no_cache 1;
fastcgi_cache_bypass $no_cache;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
        set $no_cache 1;
}
if ($query_string != "") {
        set $no_cache 1;
}

# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
        set $no_cache 1;
}

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
        set $no_cache 1;
}

if ($request_uri ~* "(/(complete|custom)-order/)") {
        set $no_cache "1;
}
Venus_Kanamo ()

немного ниже

{% if $PRESET == Wordpress %} location ~ .php$ { {% if $REDIRECT_TO_APACHE != on and $SRV_CACHE == on %} if (!-f $document_root$fastcgi_script_name) {return 404;} # This is a robust solution for path info security issue and works with «cgi.fix_pathinfo = 1» in /etc/php.ini (default) add_header X-Cache $upstream_cache_status; add_header X-NO-Cache $no_cache; add_header x-ua-device $ua_device; fastcgi_cache_bypass $no_cache; fastcgi_no_cache $no_cache; fastcgi_cache {% $NAME %}; fastcgi_cache_valid 200 [% $EXPIRES_VALUE %]; fastcgi_param HTTP_HOST $http_host; fastcgi_param HTTP_IF_NONE_MATCH $http_if_none_match if_not_empty; fastcgi_param HTTP_IF_MODIFIED_SINCE $http_if_modified_since if_not_empty; fastcgi_ignore_headers «Cache-Control» «Expires» «Set-Cookie»; fastcgi_cache_lock on; fastcgi_cache_background_update on; fastcgi_cache_revalidate on; {% if $SSI == on %} ssi_last_modified on; {% endif %} {% endif %} fastcgi_index index.php; fastcgi_param PHP_ADMIN_VALUE «sendmail_path = /usr/sbin/sendmail -t -i -f {% $EMAIL %}»; fastcgi_pass {% $PHPFPM_USER_SOCKET_PATH %}; fastcgi_intercept_errors on; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_split_path_info ^((?U).+.ph(?:p\d*|tml))(/?.+)$; include fastcgi_params; }

Venus_Kanamo ()