首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >nginx + php5-fpm + wordpress缓存

nginx + php5-fpm + wordpress缓存
EN

Stack Overflow用户
提问于 2015-11-22 07:56:09
回答 1查看 35关注 0票数 0

我有一些非常积极的缓存发生(据我所能知道的)与我的设置。

为了消除可能的浏览器缓存,我使用curl请求一个CSS文件:

代码语言:javascript
运行
复制
$ 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,我可以看到文件是被请求的:

代码语言:javascript
运行
复制
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文件:

代码语言:javascript
运行
复制
$ 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配置文件:

代码语言:javascript
运行
复制
$ 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;
                 }


}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-22 08:08:23

我运行服务器的环境是一个使用VirtualBoxvagrant机器。

事实证明,这一切都与此有关,因为VirtualBox讨厌sendfile

解决方案是修改/etc/nginx/nginx.conf并关闭sendfile

代码语言:javascript
运行
复制
http {

        ##
        # Basic Settings
        ##

        sendfile off;
        ...
}

感谢ServerFault的答案

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33852774

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档