【问题标题】:Nginx Cache doesn't refreshNginx 缓存不刷新
【发布时间】:2013-04-23 10:15:50
【问题描述】:

我将 nginx 配置为缓存所有文件 3 分钟。这仅适用于我手动上传到网络服务器的文件。 CMS 生成的所有文件都会被永久缓存(或者我没有等待很长时间)...

CMS 以“index.html”的形式提供所有页面,并具有自己的文件夹结构 (www.x.de/category1/category2/articlename/index.html)。

我该如何调试呢?有没有办法检查特定文件的生命周期? .html 文件中的某些内容可以覆盖 proxy_cache_valid 值吗?

非常感谢!

配置:

server {
listen 1.2.3.4:80 default_server;

server_name x.de;
server_name www.x.de;
server_name ipv4.x.de;


client_max_body_size 128m;
location / { # IPv6 isn't supported in proxy_pass yet.
proxy_pass http://apache.ip:7080;
proxy_cache my-cache;
proxy_cache_valid 200 3m;
proxy_cache_valid 404 1m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Accel-Internal /internal-nginx-static-location;
access_log off;

}

location /internal-nginx-static-location/ {
alias /var/www/vhosts/x.de/httpdocs/cms/;
access_log /var/www/vhosts/x.de/statistics/logs/proxy_access_log;
add_header X-Powered-By PleskLin;
internal;
}}

【问题讨论】:

    标签: caching nginx forever


    【解决方案1】:

    使用curl -I,您可以检索标头,这些标头会告诉您缓存设置是什么。

    例如

    >>> curl -I http://www.google.com
    HTTP/1.1 200 OK
    Date: Sun, 09 Feb 2014 06:28:36 GMT
    Expires: -1
    Cache-Control: private, max-age=0
    Content-Type: text/html; charset=ISO-8859-1
    Server: gws
    X-XSS-Protection: 1; mode=block
    X-Frame-Options: SAMEORIGIN
    Transfer-Encoding: chunked
    

    缓存设置是在响应标头中完成的,因此 html 无法修改这些设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多