# NGINX Cache path
fastcgi_cache_path /var/run/nginx-cache/ levels=1:2 keys_zone=phpcache:100m max_size=10g inactive=6h use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500 http_503;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
listen 80;
server_name example.com www.example.com; #Replace example.com with your intended domain name
root /var/www/wordpress; #Replace with your WordPress folder if necessary
index index.php index.html index.htm;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
set $skip_cache 0;
if ($request_method = POST) {set $skip_cache 1;}
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|/wp-.*.php|index.php|sitemap(_index)?.xml") {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;}
if ($query_string = "unapproved*") {set $skip_cache 1;}
if ($cookie_woocommerce_items_in_cart = "1" ){ set $skip_cache 1;}
if ($request_uri ~* "/(cart|checkout|my-account)/*$") {set $skip_cache 1;}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
if ($uri !~ "^/uploads/") {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
try_files $uri =404;
fastcgi_pass unix:unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache phpcache;
fastcgi_cache_valid 200 301 302 24h;
fastcgi_cache_min_uses 1;
fastcgi_cache_lock on
add_header X-FastCGI-Cache $upstream_cache_status;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_buffers 16 8k;
gzip_min_length 256;
gzip_types
application/atom+xml
application/geo+json
application/javascript
application/x-javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/vnd.api+json
application/x-perl
application/x-httpd-cgi
application/x-font-ttf
application/x-web-app-manifest+json
application/x-protobuf
application/xhtml+xml
application/xml
application/ttf
application/x-ttf
application/otf
application/x-otf
application/truetype
application/opentype
application/x-opentype
application/font-woff
application/eot
application/font
application/font-sfnt
application/wasm
application/javascript-binast
multipart/bag
multipart/mixed
font/x-woff
font/opentype
font/eot
font/otf
font/ttf
image/bmp
image/svg+xml
image/x-icon
image/vnd.microsoft.icon
text/xml
text/cache-manifest
text/css
text/js
text/javascript
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/xml
text/richtext
text/x-script
text/x-component
text/x-java-source
text/x-markdown
text/x-cross-domain-policy;
}Debian 11 var arkadaşlar.location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off; anladığım kadarı ile browser cache özelliği ama çok emin değilim.
Site cloudflareye ekli sorunum cache çalışıyor ama cloudflarede browser cache kısmında bir ayar var. Respect existing headers diye. Yani var olan headerları kullan. Ben bunu seçince page nginx cache ön plana çıkacak ve onun ayarlarını kullanacak diye düşündüm.
Ama bu ayarda bile;
curl -I http://www.your-domain.com ile hep 7 gün ve cloudflare cacheleme gözüküyor.
Ben nginx cacheyi test için ancak domainden a kaydı oluşturup cloudflare devredışı bırakmam lazım ama size sormak istedim.
Yapılandırmam nasıl sizce?
Nginx helper kurmadım cacheyi rm -rf /var/run/nginx-cache7* komutu ile siliyorum.
Söylemek istediklerim bukadar.
Yarımcı olan tüm arkadaşlara teşekkür ederim.
Sistemde sorun yok nginx cache ayarı şu şekilde kullanıyorum
sudo ln -s /etc/nginx/sites-available/sizinalanadiniz.com /etc/nginx/sites-enabled/
Daha önce loader iodan tesler yapmıştım plesk çok ciddi iyi sonuç alıyordu. Bir hatam sunucu yedeğini alsam geri döndürebilirdim 