LNMP 配置靜態檔案快取

2021-09-20 22:34:47 字數 556 閱讀 3518

配置靜態檔案快取的作用是「提高速度,節省頻寬」

編輯"虛擬主機配置檔案"

[root@lamplinux ~]# vim /usr/local/nginx/conf/vhosts/test.conf

找到「不記錄指定檔案日誌」配置,新增更改(紅字):

因為還有兩種js和css,我們不能直接用下面一段關於(static|cache)不記錄指定日誌的配置,因為static和cache目錄內不僅僅只是js和css的檔案,所以,我們需要接上面一段,重新寫乙個配置

location ~ \.(js|css)

[root@lamplinux ~]# /usr/local/nginx/sbin/nginx -t

[root@lamplinux ~]# /usr/local/nginx/sbin/nginx -s reload

瀏覽網頁,按f12,可以檢視快取穩健的過期時間。

SpringBoot 配置靜態檔案快取

spring resources chain strategy content enabled true paths cache true compressed false enabled true cache cachecontrol cache public trueimport org.spr...

LNMP相關配置檔案 LNMP相關目錄

nginx usr local nginx mysql usr local mysql php usr local php 目錄 home wwwroot nginx日誌目錄 home wwwlogs root vhost.sh新增的虛擬主機配置檔案所在目錄 usr local nginx conf...

nginx 靜態檔案快取

目的 快取nginx伺服器的靜態檔案。如css,js,htm,html,jpg,gif,png,flv,swf,這些檔案都不是經常更新。便於快取以減輕伺服器的壓力。實現 nginx proxy cache可以將使用者的請快取到本地乙個目錄,當下乙個請求時可以直接調取快取檔案,就不用去後端伺服器去取檔...