Wordpress nginx 静态web服务器 缓存 cache

分享
Wordpress nginx 静态web服务器 缓存 cache

Wordpress nginx 静态web服务器 缓存 cache

1.首先wordpress安装nginx helper 插件,帮助你在修改文章添加文章 这些情况下 自动刷新对应页面缓存的作用

2.WEB服务器准备:

首先给nginx添加nginx_cache_purge缓存清除模块

模块项目地址:官方一直没更新的模块版本地址为https://github.com/FRiCKLE/ngx_cache_purge

官方偷偷更新的新版本清除模块,在debian 官方模块里 哈哈,如果使用debian官方自带的nginx,那你可以使用apt来安装 libnginx-mod-http-cache-purge 这个模块

如果你想使用自己编译的nginx并使用这个最新的模块 项目地址为:https://salsa.debian.org/nginx-team/libnginx-mod-http-cache-purge 切换分支为upstream 这个就是最新版本 2.5.3

编译方法为:

nginx -V    ###查看编译参数
在编译参数最后 添加 
--add-module=/xxx/libnginx-mod-http-cache-purge/  ### xxx替换为模块文件夹的绝对位置
编译完成后 直接复制nginx编译文件夹下面的objs/nginx 替换 重启服务就行了

接下来开始设置nginx 的配置:

首先在http块里添加如下参数:

fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

第一行参数里的WORDPRESS可以修改为任意名称,这个是缓存识别的名称

接下来在对应域名server块配置里添加如下参数:

# POST requests and urls with a query string should always go to PHP
set $skip_cache 0;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
    set $skip_cache 1;
}
if ($query_string != "") {
    set $skip_cache 1;
}

# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
    set $skip_cache 1;
}

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
    set $skip_cache 1;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}

location purge这个里面的WORDPRESS记得修改为你对应的缓存标识

接下来还需要在 location php 这个识别php文件的里面添加如下参数:

fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid  60m;

保存配置 重启nginx 缓存已经配置完成 然后开启nginx helper 可以自动清除缓存

阅读更多

Windows11 24h2 显示器手动校色后正确生效方法

Windows11 24h2 显示器手动校色后正确生效方法

1.正常使用校色仪自带软件或displaycal生成的校色文件 嵌入后不会正确生效,可使用MHC2GEN来对校色文件进行转换,转换成可以生效的现代校色文件。 2.工具来源地址为github:https://github.com/dantmnf/MHC2 3.使用方法: 注:以下均为powershell或cmd执行,执行文件从上述地址中下载 MHC2Gen.zip文件 示例1:为SDR自动色彩管理创建配置文件 MHC2Gen.exe sdr-acm --calibrate-transfer "C:\...\DisplayCAL\存储路径\...\校色文件.icm" "MODEL SDR ACM.icm" 后面的第一个路径为需要转换的源文件路径,后面的为输出路径,默认只输入文件名则只在mhc2gen路径下创建 示例2:sRGB proofing / clamp / emulation in SDR

By asumi233
qnap 使用 acme.sh ssl 证书

qnap 使用 acme.sh ssl 证书

提前申明/share 目录是共享文件夹的目录 记得提前创建好共享文件夹 /share/共享文件夹名 1.首先安装 acme.sh 配置环境变量 安装的位置 export LE_WORKING_DIR=/share/acme-ssl/.acme.sh 安装 记得把邮件地址替换成你自己的 curl https://get.acme.sh | sh -s email=my@example.com 安装完以后创建一个脚本 后面需要用到 这个脚本的内容是帮助你替换 ssl 以及重启服务 #!/bin/bash DN=$1 cat $DN.key $DN.cer ca.cer

By asumi233