簡體   English   中英

nginx + php5-fpm + wordpress緩存

[英]nginx + php5-fpm + wordpress caching

我的設置中發生了一些非常激進的緩存(據我所知)。

為了消除可能的瀏覽器緩存,我使用curl請求CSS文件:

$ curl http://localhost:8080/wp-content/plugins/zip-recipes/plugins/VisitorRating/styles/css-stars.css?ver=4.3.1
.br-theme-css-stars .br-widget {
  height: 28px;
}
.br-theme-css-stars .br-widget a {
  text-decoration: none;
  height: 18px;
  width: 18px;
  float: left;
  font-size: 23px;
  margin-right: 2px;
}
.br-theme-css-stars .br-widget a:after {
  content: "\2605";
  position: absolute;
  color: #dddddd;
}
.br-theme-css-stars .br-widget a.br-active:after {
  color: #ffdf88;
}
.br-theme-css-stars .br-widget a.br-selected:after {
  color: #ffdf88;
}
.br-theme-css-stars .br-widget .br-current-rating {
  display: none;
}

在服務器上,查看/var/log/nginx/access.log ,可以看到正在請求文件:

10.0.2.2 - - [22/Nov/2015:07:51:02 +0000] "GET /wp-content/plugins/zip-recipes/plugins/VisitorRating/styles/css-stars.css?ver=4.3.1 HTTP/1.1" 200 517 "-" "curl/7.43.0"

然后,我cat在服務器上的文件:

$ cat /wordpress_env/wp-content/plugins/zip-recipes/plugins/VisitorRating/styles/css-stars.css
.br-theme-css-stars .br-widget {
  height: 28px;
}
.br-theme-css-stars .br-widget a {
  text-decoration: none;
  height: 18px;
  width: 18px;
  float: left;
  font-size: 23px;
  margin-right: 2px;
}
.br-theme-css-stars .br-widget a:after {
  content: "\2605";
  position: absolute;
  color: #dddddd;
}
.br-theme-css-stars .br-widget a.br-active:after {
  color: #ffdf88;
}
.br-theme-css-stars .br-widget a.br-selected:after {
  color: #CE0B15;
}
.br-theme-css-stars .br-widget .br-current-rating {
  display: none;
}

請注意,最后一種color:與返回瀏覽器的color:不同。

我不確定是什么緩存了,但是我需要它停止:)

更新 :這是nginx配置文件:

$ cat /etc/nginx/sites-enabled/wordpress 
server {
        listen   8080;


        root /wordpress_env;
        index index.php index.html index.htm;

        location / {
        expires -1;
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;
        }

        location ~ \.php$ {
                try_files $uri =404;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
                 }


}

我運行服務器的環境是使用vagrantVirtualBox計算機。

事實證明,這與它有關,因為VirtualBox討厭sendfile

解決方案是修改/etc/nginx/nginx.conf並關閉sendfile

http {

        ##
        # Basic Settings
        ##

        sendfile off;
        ...
}

感謝ServerFault 的回答

暫無
暫無

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

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