簡體   English   中英

帶有緩存的Nginx WordPress配置

[英]nginx WordPress config with caching

我在RHEL伺服器上,想讓我的nginx設定來提供快取服務的WP網站,真是令人費解。 我想在nginx層處理緩存,而不是費心處理WP插件,因為我認為它將更加可靠(可以使用nginx緩存清除插件來幫助WP處理清除)。 尚未找到實際在緩存上返回HIT的配置設置組合。 下面的配置-希望大家都能看到我所缺少的東西(我已經刪除了所有緩存配置,因為它們都不起作用-對於標准的WP設置,這基本上是從nginx站點直接獲得的):

add_header Fastcgi-Cache $upstream_cache_status;

# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/tmp/php-cgi.socket;
server 127.0.0.1:9000;
}

server {
listen   80;
listen   [::]:80;
listen   443 ssl;

## Your website name goes here.
server_name intranet-test.*;
root /var/www/html/intranet;
index index.php index.html index.htm;

ssl_certificate        /etc/httpd/conf.d/certificates/intranet-test.cer;
ssl_certificate_key  /etc/httpd/conf.d/keys/intranet-test.key;

if ($scheme = http) {
return 301 https://$server_name$request_uri;
}

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

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

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}

}

要設置nginx的緩存,需要添加什么內容?

更改

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}

location ~* \.(?:ico|jpg|jpeg|png|gif|svg|js|css|swf)$ {
    add_header Cache-Control "public";
    add_header X-Frame-Options "SAMEORIGIN";
    expires 1y;
    access_log off;
}

location ~* \.(?:ttf|eot|woff|otf|woff2)$ {
    add_header Access-Control-Allow-Origin "*";
    add_header Cache-Control "public";
    add_header X-Frame-Options "SAMEORIGIN";
    expires 1y;
    access_log off;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM