• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question WordPress Cache Problem

bmalkoc

Basic Pleskian
Hello. I tried all popular cache plugins but WordPress cache doesn't work in nginx. I think it is related to nginx configuration. I am using this code (found in plesk website). Is that correct? Or what can i do for fix this?

Code:
# WORDPRESS PERMALINKS
if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?q=$1 last;
}

# GZIP Compression
gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_proxied any;
gzip_comp_level 9;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;

# NGINX Caching
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff)$ {
    expires 30d;
    add_header Cache-Control "public";
    log_not_found off;
}

location ~* \.(jpg|jpeg|gif|png)$ {
    expires 365d;
    log_not_found off;
}

location ~* \.(pdf|css|html|js|swf)$ {
    expires 2d;
    log_not_found off;
}

location ~ \.css {
    add_header  Content-Type    text/css;
}
location ~ \.js {
    add_header  Content-Type    application/x-javascript;
}

# SECURITY
location ~* wp-config.php { deny all; }
location ~* "^/wp-content/(?!plugins/).*\.php" { deny all; }
 
Hi,
where have you found the config above?
You can try removing the #SECURITY-Part at the bottom, maybe this is blocking the access.
Have you disabled the "Proxy mode"?
 
Hi,
where have you found the config above?
You can try removing the #SECURITY-Part at the bottom, maybe this is blocking the access.
Have you disabled the "Proxy mode"?
Hello thanks for your reply. I don't remember where i found. I deleted security section but doesn't work. Also proxy mode is disabled.
 
Alright, which caching plugin are you using?
I would try removing the whole #NGINX Caching section and let it handle with the wp caching plugin.
 
For me, wp rocket is working fine (disabled proxy mode, no nginx caching, no serving of static files by nginx).
Which php handler are you using?
 
I've no additional nginx settings configured which would affect anything like that.
How do you check if the files are cached or not?
 
Your "Additional nginx directives" empty right?

I am checking cache from source code. There is must be "<!-- This website is like a Rocket, isn't it? Performance optimized by WP Rocket." text. And scripts not minified and combined.
 
Are you using cloudflare or something else that might be caching the website before your wp rocket installation?
 
Back
Top