???? ???? ?????? ?? Nginx ?? ?? ??
????? ??? ? ???? ??? ??? ??? ?? ??? ???? ?? Nginx? ??? ??? ??? ???? ??? ????. ??? ???? ???? ????? ? ???? ?? ???? ?? ???? ? ??? ??? Nginx? ??? ??? ???. ? ????? ? ??? ???? ?? ??? ???? ?? Nginx ?? ??? ???? ??? ?????.
1. ?? ?? ??
?? Nginx? ?? ??? ???? ???. Nginx ?? ??(????? /etc/nginx/nginx.conf
?? /etc/nginx/conf.d/default.conf
)? ?? http ??? ?? ??? ?????. <code>/etc/nginx/nginx.conf
或/etc/nginx/conf.d/default.conf
,找到http
段,添加以下配置:
http { ... proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off; server { ... } ... }
上述配置將緩存文件存儲(chǔ)在/var/cache/nginx
目錄下,并設(shè)置了緩存大小為10GB,緩存過(guò)期時(shí)間為60分鐘。需要根據(jù)實(shí)際情況進(jìn)行調(diào)整。
二、配置緩存清理接口
接下來(lái),我們需要配置一個(gè)接口用于清理Nginx的緩存。
在Nginx的配置文件中,找到需要清理緩存的地方,比如一個(gè)POST請(qǐng)求:
http { ... server { ... location /update { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; # 清理緩存 proxy_cache_purge my_cache GET POST; } ... } ... }
上述配置中,location /update
用于匹配需要更新的URL路徑,比如/update
。proxy_cache_purge
指令用于清理緩存,參數(shù)GET POST
表示同時(shí)清理GET和POST請(qǐng)求的緩存??梢愿鶕?jù)實(shí)際情況進(jìn)行調(diào)整。
三、安裝Purge模塊
Nginx的默認(rèn)安裝中并不包含proxy_cache_purge
模塊,我們需要手動(dòng)安裝。
使用以下命令安裝Nginx的模塊管理工具:
yum install -y yum-utils
使用以下命令添加Nginx的擴(kuò)展源:
yum-config-manager --add-repo=https://nginx.org/packages/centos/7/x86_64/
最后,使用以下命令安裝Nginx的nginx-module-cache-purge
模塊:
yum install -y nginx-module-cache-purge
四、重啟Nginx服務(wù)
完成以上配置后,需要重啟Nginx服務(wù)使配置生效。使用以下命令重啟Nginx:
systemctl restart nginx
五、清理緩存的方式
現(xiàn)在,我們可以通過(guò)訪(fǎng)問(wèn)清理緩存的接口來(lái)實(shí)現(xiàn)清理Nginx的緩存。比如,如果我們要清理/update
路徑的緩存,可以使用以下命令:
curl -X POST http://yourdomain.com/update
這樣就會(huì)觸發(fā)Nginx清理/update
路徑下的緩存。
六、自動(dòng)清理緩存
為了保證網(wǎng)站內(nèi)容的更新,我們可以通過(guò)定期清理緩存的方式,自動(dòng)保持Nginx中的緩存與實(shí)際網(wǎng)站內(nèi)容的一致性。
我們可以使用定時(shí)任務(wù)工具(如Cron)來(lái)定期執(zhí)行清理緩存的命令。比如,設(shè)置每天凌晨4點(diǎn)清理一次緩存,可以使用以下命令編輯定時(shí)任務(wù):
crontab -e
然后添加以下一行命令:
0 4 * * * curl -X POST http://yourdomain.com/update >> /tmp/nginx_cache_clear.log 2>&1
保存并退出編輯器,這樣每天凌晨4點(diǎn)就會(huì)觸發(fā)一次清理緩存的操作,并將執(zhí)行結(jié)果保存在/tmp/nginx_cache_clear.log
rrreee
/var/cache/nginx
????? ???? ?? ??? 10GB? ???? ?? ?? ??? 60?? ?????. ?. ?? ??? ?? ??? ?????. 2. ?? ?? ????? ?????? Nginx ??? ???? ?? ?????? ???? ???. ????Nginx ?? ???? POST ??? ?? ??? ??? ?? ??? ????. ??rrreee??? ????? location /update
? ???? URL ??? ??????. ????? ??? ??(?: /update
) proxy_cache_purge
???? ??? ??? ? ????, GET POST
????? GET ? POST ??? ??? ??? ??? ?? ?????. ?? ??? ?? ??? ? ????. ????3. ?? ?? ?? ????Nginx? ?? ???? proxy_cache_purge
??? ???? ?? ???? ???? ???? ???. ?????? ??? ???? Nginx? ?? ?? ??? ?????. ??rrreee???? ??? ???? Nginx? ?? ??? ?????. ??rrreee??????? ?? ??? ???? Nginx? nginx-module-cache-purge? ?????. code> module :??rrreee??4. Nginx ??? ?? ??????? ??? ??? ? ??? ????? Nginx ???? ?? ???? ???. Nginx? ?? ????? ?? ??? ??????. ??rrreee?? 5. ??? ??? ?? ???? ?? ?? ?? ?????? ????? Nginx ??? ??? ? ????. ?? ??, <code>/update
???? ??? ???? ?? ??? ??? ? ????: ??rrreee????? ?? Nginx? /update ?????. ???? 6. ???? ?? ??? ???? ???? ???? ???????? ???? ?? ????? ??? ???? Nginx? ??? ?? ???? ??? ?? ???? ???? ??? ? ????. ????Cron? ?? ?? ?? ??? ???? ????? ?? ??? ??? ??? ? ????. ?? ?? ?? ?? 4?? ??? ????? ????? ?? ??? ???? ??? ??? ??? ? ????. ??rrreee?? ?? ?? ?? ?? ?? ?????. ??rrreee?? ???? ???? ?????. ?? ?? 4?? ?? ?? ??? ????, ?? ??? <code>/tmp/nginx_cache_clear.log
??? ?????. ??????????? ??? ?? Nginx ??? ???? ???? ???? ???? ?? ??? ??? ? ????. ??? ??? ? ??? ?? ??? ?? ??? ?? ?? ??? ?? ??? ???? ??? ?? ????. ??? ??? ???? ???? ?? ??? ???? ?? Nginx ?? ?? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

win11?? ??? ??? ??? ??? ? ???? ???? ???? ???? ?? C ????? ?? ??? ???? 10GB ??? ???? ?? ??? ?? ??? ????. ??, win11? ???? ???? ??? ?? ??? ???? ?? ???? ???? ??? ????? ??? ???. ??? ?? ????? win11? ??? ?? ??? ??? ???, ??? ????? ?? ????. ?? ???? Win 11? ???? ?? ?? ??? ???? ??? ??? ???????. win11? ??? ?? ?? ??? ???? ?? 1. ?? ???? [Win] ?? ???? ?? ???? [?? ??]? ??? ? ??? ?? ???? ??? [??]? ?????. : ??? > ????,

?? ?? ???? C ????? ??? ??? ? ?? ??? ????? ??? ???? ?? ???? ?? ?? ???? ??? ????? ??? ??? ?? ????. ?? ??? ?? ???? ??? ? ????. Win10?? C ????? ????? ??? ??? ?????? ??: Win10?? C ????? ????? ??? ??? ?????. 1. ????? win+r ???? ???? ???? ??? ? Enter ?? ????. 2. ???? ???---. 3. ?? ?? ? ????? ???? ?????. 4. ????? ??? ?????. 5. ????? ??? ???? ?? ???? ?? ? ???? ?? ??? ?? C ????? ?? ?????.

Linux ??? ?? ? ?? ??? ?? ???? ?? ? ?? ??? ???? ??? ??? ??? ???? ???? ?? ?? ?? ??? ?? ? ??? ?? ???? ??? ?????. ??? ?? ???? ??? ??? ??? ?? ??? ??? ?? ? ?? ????? ??? ?? ? ????. ? ????? Linux ???? ?? ? ?? ??? ?? ???? ???? ??? ?? ???? ? ?? ?? ??? ?????. 1. Linux ??? ?? ?? ???? ??? ??, ?????? ??,

? ??? ???? ?? ??? ???? ?? Nginx ?? ?? ?? ? ???? ??? ? Nginx? ??? ??? ??? ???? ? ??? ??? ??? ??? ?? ??? ???? ??? ????. ??? ???? ???? ????? ? ???? ?? ???? ?? ???? ? ??? ??? Nginx? ??? ??? ???. ? ????? ? ??? ???? ?? ??? ???? ?? Nginx ?? ??? ???? ??? ?????. 1. ?? ?? ?? ?? Nginx? ?? ??? ???? ???. Nginx ?? ??

?? win10 ???? C ?????? hiberfil.sys ??? ? ? ???, ? ??? ???? C ????? ?? ?? ???? ??? ????. ??? C ????? ??? ?? ???? ? ??? ????? ????. ??? ??? ??? ?????. 1. ?? ?? ?? ??? ???? ?? ??? ?? ?? ?? ?? ??? ?????. 2. c ????? ?? ???? ?? ?? ??? ??? ?????. ?? hiberfil.sys? ?? ?? ?? ?????. ???? cmd ?? ?? ???. ?? ????? ??? ??? ?? ? ????. ??? ?????? ?? cmd ??? ?? ??? ??? ??? ???? ??? ???? ??? ? ????. 3. ?? ?? powercfg-hoff? ???? ?? ?? ?? ??? ???? ???, ?? ?? ?? ??? ???? ????.

Win7 ???? ?? ???? ?? ??? ???? ??? ?? ???? ?? ??? ??? ?? ?? ???? ???? ???. ???? ? ??? ???? ???? ??? ??? ???? ??? ???????. Windows 7?? ?? ? ??? ???? ?? 1. ??? ???? ?? ??? ??? ??? ??? ? ??? ?????. 2. ???? ?? ???? ?? ??? ?????. ???? ???? "??? ??"? ?????. 3. ??? ? ???? ??? ??? ???? ??? ?????.

QQ ???? ?? ???? ??? ??? ?????? QQ ????? ??? ??? ??? ???? ?? ?? ???? ????? ???? ?? ????????. ?? ??? ?????? ???? ???? ?? ?? ??? ?? ?? ??? ?? ??? ?? ?? ????. ??? ???? ??? ????? ?? ??? ?????. ?? ????? ??? ??? ???? ??? ? ????? ?? ??? ?????. QQ ???? ?? ? ??? ???? ??? ???????! QQ ???? ?? ??? ?? ?? ? ??? ?????. 1??: QQ ????? ?? ?? ??? ??? ??? ?? "??" ???? ?????. 2??: ???? ?? ??? ???? ??? ?????.

?? ???? ??? ? ??? ?? ??? ?? ????? ?? ???? ???? ???? ??? ???? ??? ??? ? ????. ? ?????? ?? ???? ??? ???? ????? ?? ???? ???? ? ??? ?? ? ?? ???? ???? ??? ?????. 1. ?? ?? ??? ?? ??? ??? ???? ?? ??? ?????. ??? ??? ??? ??? ?? ??? ? ????. ?? ???? ?? ??? ?? "???" ???? "?? ???" ?? "?? ???" ??? ?? ???? ?????. ?? ?? ?? ???? ???? ??? ??? ??? ?????. 2. ???? ? ?? ??? ?? ?????? ???? ? ? ??? ???? ??? ?????? ??? ??? ??????? ?? ??? ?????.
