日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

nginx配置静态文件过期时间

發布時間:2023/12/13 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx配置静态文件过期时间 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 編輯虛擬主機配置文件/usr/local/nginx/conf/vhosts/huangzhenping.conf

? ? 說明:采用location方式

1 2 3 4 5 6 7 8 9 10 ?location?~?.*\.(gif|jpg|jpeg|png|bmp|swf)$ ????{ ????access_log?off; ????expires?1d; ????} ????location?~?\.(js|css) ????{ ???????access_log?off; ???????expires?1d; ????}

? ?

?

2. 檢查配置文件,重新加載,測試

? ? 說明:google瀏覽器可以按F12,查看開發者工具或者用curl測試

? ? /usr/local/nginx/sbin/nginx -t

? ? /usr/local/nginx/sbin/nginx -s reload

?

?

? ? curl -x127.0.0.1:80 http://www.huanglearn.cn/static/image/smiley/default/mad.gif -I

?

?

?

實際配置:

server {listen 80;server_name www.weifeng.cn;location /api/ {proxy_pass http://127.0.0.1:8088/; proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}location / {try_files $uri /index.html;root /home/*****ui/build;index index.html index.htm;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${access_log off;expires 10d;root /home******/ui/build;}location ~ \.(js|css){access_log off;expires 10d;root /home******/ui/build;}}

測試效果:

?

curl -x127.0.0.1:80 http://www.weofemg.cn/static/js/main.5770cbc7.js -I HTTP/1.1 200 OK Server: nginx/1.14.0 Date: Thu, 30 Aug 2018 06:55:51 GMT Content-Type: application/javascript Content-Length: 412411 Last-Modified: Wed, 29 Aug 2018 12:28:50 GMT Connection: keep-alive ETag: "5b869182-64afb" Expires: Sun, 09 Sep 2018 06:55:51 GMT Cache-Control: max-age=864000 Accept-Ranges: bytes

?

轉載于:https://www.cnblogs.com/weifeng1463/p/9560311.html

總結

以上是生活随笔為你收集整理的nginx配置静态文件过期时间的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。