1. 程式人生 > >nginx配置靜態文件過期時間

nginx配置靜態文件過期時間

location 記錄 設置 index http ont 分鐘 文件 for

1、配置指定文件不記錄日誌,同時設置靜態文件過期時間
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 15d;
access_log off;
}
2、只配置靜態文件過期時間
#配置靜態文件過期時間
location ~ \.(js|css)$
{
expires 15d;
}
d 天 h 小時 m 分鐘

用curl 查看本地127.0.0.1訪問。
如:curl -x127.0.0.1:80 www.dd.com/data/cache/style_1_forum_index.css?x70 -I
-A:可以指定瀏覽器標識user_agent
-I: 可以只查看狀態信息。

技術分享

其中Cache-Control一行就是過期時間,默認時間單位為秒

nginx配置靜態文件過期時間