我运行nginx服务器+ PHP webservices API.我使用nginx的fastcgi_cache来缓存所有GET请求,当更新某些资源时,我清除一个或多个相关的缓存资源.

我用来执行此操作的方法是为要清除的每个资源计算nginx缓存文件名,然后删除该文件.在大多数情况下,这很有效.

但是,我发现有时,即使删除了缓存文件,nginx仍然会从缓存中返回数据.

这不是选择要删除的正确缓存文件的问题 - 作为我测试的一部分,我删除了整个缓存目录,并且nginx仍然返回HIT响应

有人知道为什么会这样吗?是否可能涉及另一个缓存?例如,操作系统是否正在将缓存文件的缓存版本返回给nginx,因此nginx不知道它已被删除?

我在CentOS上运行它,并使用这个nginx配置(减去不相关的部分):

user nginx;

# Let nginx figure out the best value

worker_processes auto;

events {

worker_connections 10240;

multi_accept on;

use epoll;

}

# Maximum number of open files should be at least worker_connections * 2

worker_rlimit_nofile 40960;

# Enable regex JIT compiler

pcre_jit on;

http {

# TCP optimisation

sendfile on;

tcp_nodelay on;

tcp_nopush on;

# Configure keep alive

keepalive_requests 1000;

keepalive_timeout 120s 120s;

# Configure SPDY

spdy_headers_comp 2;

# Configure global PHP cache

fastcgi_cache_path /var/nginx/cache levels=1:2 keys_zone=xxx:100m inactive=24h;

# Enable open file caching

open_file_cache max=10000 inactive=120s;

open_file_cache_valid 120s;

open_file_cache_min_uses 5;

open_file_cache_errors off;

server {

server_name xxx;

listen 8080;

# Send all dynamic content requests to the main app handler

if (!-f $document_root$uri) {

rewrite ^/(.+) /index.php/$1 last;

rewrite ^/ /index.php last;

}

# Proxy PHP requests to php-fpm

location ~ [^/]\.php(/|$) {

# Enable caching

fastcgi_cache xxx;

# Only cache GET and HEAD responses

fastcgi_cache_methods GET HEAD;

# Caching is off by default, an can only be enabled using Cache-Control response headers

fastcgi_cache_valid 0;

# Allow only one identical request to be forwarded (others will get a stale response)

fastcgi_cache_lock on;

# Define conditions for which stale content will be returned

fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503;

# Define cache key to uniquely identify cached objects

fastcgi_cache_key "$scheme$request_method$host$request_uri";

# Add a header to response to indicate cache results

add_header X-Cache $upstream_cache_status;

# Configure standard server parameters

fastcgi_split_path_info ^(.+\.php)(/.+)$;

include fastcgi_params;

# php-fpm config

fastcgi_param SCRIPT_URL $fastcgi_path_info;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param REQUEST_SCHEME $scheme;

fastcgi_param REMOTE_USER $remote_user;

# Read buffer sizes

fastcgi_buffer_size 128k;

fastcgi_buffers 256 16k;

fastcgi_busy_buffers_size 256k;

fastcgi_temp_file_write_size 256k;

# Keep connection open to enable keep-alive

fastcgi_keep_conn on;

# Proxy to PHP

fastcgi_pass unix:/var/run/php-fpm/fpm.sock;

}

}

}

现在我看一下,open_file_cache参数是否会影响缓存文件?

有任何想法吗?

nginx服务器缓存文件清理,清除nginx缓存文件并不总是有效相关推荐

  1. nginx服务器网站文件存放处,Nginx服务器安装部署

    获取新版本的Nginx服务器 Nginx的官方下载网站为http://nginx.org/en/download.html .进入网站可以看到三种版本,开发版本(Development version ...

  2. linux+nginx+清楚缓存,缓存 – 清除nginx缓存文件并不总是有效

    我运行一个nginx服务器 PHP webservices API.我使用nginx的fastcgi_cache来缓存所有GET请求,当更新某些资源时,我清除一个或多个相关的缓存资源. 我用来执行此操 ...

  3. nginx服务器网站目录浏览,Nginx开启目录浏览功能 | 系统运维

    说明:Nginx在默认安装好之后,是禁止目录浏览的,如下图所示 系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容版权所有,转载请注明出处及原文链接 http://www. ...

  4. 宝塔修改Nginx服务器类型,宝塔面板nginx更改日志格式的方法

    宝塔默认的日志格式比较简单,可能有些站长需要自定义日志格式,而不知道从何下手,其实这个就是简单的定义nginx的过程 只是宝塔的nginx配置文件存放位置与一般nginx不一样 宝塔存放nginx配置 ...

  5. 向nginx服务器上传文件,Nginx搭建上传服务器

    使用 Nginx Upload Module 上传文件 安装编译环境:yum -y install gcc gcc-c++kernel-devel 创建目录:mkdir /tmp/nginx 进入目录 ...

  6. nginx服务器查看日志文件,nginx服务器中access_log日志分析与配置详解

    前言 nginx的log日志分为:access log 和 error log 其中access log 记录了哪些用户,哪些页面以及用户浏览器.ip和其他的访问信息 error log 则是记录服务 ...

  7. 修改thinkphp配置nginx服务器,thinkphp5.0配置nginx重写规则

    thinkphp5.0配置nginx重写规则 2018年07月06日 09:29:03阅读数:1529 server { listen 80; #端口号 server_name demo.aa.com ...

  8. nginx服务器远程无法访问,nginx首次安装远程无法访问

    因为是问题.花时间.所以进行记录一番 (一)安装环境:虚拟机centos7系统 对于nginx在linux下的安装卸载是装了又卸,卸了又装.远程访问就是访问不了,周五的时候能访问,到后面又不能访问了. ...

  9. Nginx服务器--Nginx服务器的使用笔记

    1.Nginx简介 Nginx("engine x") 一个具有高性能的[HTTP]和[反向代理]的[WEB服务器],同时它也是一个[POP3/SMTP/IMAP代理服务器],由伊 ...

最新文章

  1. 【总结整理】关于切图
  2. 解题报告——蓝桥杯 试题 基础练习 2n皇后问题(附n皇后代码)
  3. [原创]FineUI秘密花园(二十七) — 窗体控件概述(上)
  4. 闭包--闭包作用之保护(一)
  5. 牛客网【每日一题】4月17日题目精讲 华华给月月准备礼物
  6. 微博机器学习平台云上最佳实践
  7. qt如何把父窗口的变量传给子窗口_父窗口和iframe子窗口之间相互传递参数和调用函数或方法...
  8. UVa 202 Repeating Decimals
  9. bzoj 2844 子集异或和名次
  10. (HDU-1564)Play a game(博弈论)
  11. 内盘外盘哪个比较好?如何分析
  12. Paypal 实现自动订阅
  13. TwinCAT3 与 SMC(EX600总线模块)通讯
  14. Win11色温如何进行调整设置
  15. matlab串口陀螺仪,matlab通过串口接收ARM7外设陀螺仪数据并绘图有困难急求解答...
  16. 面试经验//Java新手如何制定优秀的职业规划?看大牛怎么说!
  17. 跑步时你最关心配速吗,真正会跑步的人更看重这个
  18. 2021年复旦大学961真题回顾
  19. XeLaTeX下LaTeX中文字体加粗解决方案
  20. 腾讯广点通广告投放-转化归因API回传接口对接踩坑指南

热门文章

  1. Datewhale组队学习——深度学习推荐系统(1)
  2. 可视化,市场分析表Excel模板,财务统计EXCEL模版,人员变动EXCEL模版,销量完成度Excel模板
  3. golang 时间missing Location in call to Date
  4. Titanic 泰坦尼克号预测-Tensorflow 方法-【Kaggle 比赛】
  5. androidstudio的语音唤醒功能
  6. python-求无理数e的近似值
  7. 微信发布4条新规!再也不用帮好友拼团砍价了,网友纷纷称赞
  8. SLCP认证辅导,SLCP整合评估框架包含三个要素及验证步骤
  9. lstm 文本分类_带有lstm和单词嵌入的灾难推文上的文本分类
  10. Elasticsearch5基于completion suggester实现提示词(类京东淘宝)