【问题标题】:nginx + php5-fpm + wordpress cachingnginx + php5-fpm + wordpress 缓存
【发布时间】:2016-02-24 11:32:35
【问题描述】:

我的设置发生了一些非常激进的缓存(据我所知)。

为了消除可能的浏览器缓存,我使用 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: 与返回给浏览器的不同。

我不确定是什么在缓存它,但我需要它停止 :)

更新:这是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;
                 }


}

【问题讨论】:

    标签: caching nginx vagrant virtualbox fastcgi


    【解决方案1】:

    我运行服务器的环境是使用vagrantVirtualBox 机器。

    事实证明这与它有关,因为VirtualBox hates sendfile

    解决办法是修改/etc/nginx/nginx.conf,关闭sendfile

    http {
    
            ##
            # Basic Settings
            ##
    
            sendfile off;
            ...
    }
    

    感谢 ServerFault 提供the answer

    【讨论】:

      猜你喜欢
      • 2017-01-21
      • 1970-01-01
      • 2016-06-11
      • 2012-05-15
      • 2014-08-19
      • 1970-01-01
      • 2014-08-17
      • 2012-12-05
      • 1970-01-01
      相关资源
      最近更新 更多