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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

虚拟机玩转缓存服务器,Nginx服务器中浏览器本地缓存和虚拟机的相关设置

發布時間:2025/3/19 HTML 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 虚拟机玩转缓存服务器,Nginx服务器中浏览器本地缓存和虚拟机的相关设置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

自動列出目錄配置:

下載過開源軟件的都知道,一個很簡單的頁面列出了所有版本的源碼包,這就是開啟了自動列出目錄

如下配置,在虛擬主機location / {……}目錄控制中配置自動列出目錄:

location / {

autoindex on;

}

瀏覽器本地緩存設置:

瀏覽器是為了加速瀏覽,瀏覽器在用戶磁盤上對最近請求過的文件進行存儲,當訪問者再次請求這個頁面,

瀏覽器可以從本地磁盤顯示文件,以達到加速瀏覽的效果,節約了網絡資源,提高了網絡效率

關鍵字: expires

默認值: off

作用域: http,server.location

用途: 通過expires指令控制http應答中的”Expires”和”Cache-Control”的頭信息

配置項:

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 1h;

}

配置虛擬主機:

nginx可以配置多種類型的虛擬主機,基于ip的 基于域名的 基于端口的,

簡單一句話說就是不同ip相同端口,不同端口相同ip or域名,不同域名相同端口

下面是基于相同域名的虛擬主機配置文件:

server {

listen 80 default;

server_name www.wpython.com;

index index.html index.htm index.php;

root /alidata/www/www.wpython.com;

# wordpress 偽靜態規則

location / {

if (-f $request_filename/index.html){

rewrite (.*) $1/index.html break;

}

if (-f $request_filename/index.php){

rewrite (.*) $1/index.php;

}

if (!-f $request_filename){

rewrite (.*) /index.php;

}

}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

location ~ .*\.(php|php5)?$

{

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 1h;

}

access_log /alidata/log/nginx/access/www.wpython.com.log;

}

server {

listen 80 default;

server_name www.pyyw.net;

index index.html index.htm index.php;

root /alidata/www/www.pyyw.net;

# wordpress 偽靜態規則

location / {

if (-f $request_filename/index.html){

rewrite (.*) $1/index.html break;

}

if (-f $request_filename/index.php){

rewrite (.*) $1/index.php;

}

if (!-f $request_filename){

rewrite (.*) /index.php;

}

}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

location ~ .*\.(php|php5)?$

{

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 1h;

}

access_log /alidata/log/nginx/access/www.pyyw.net.log;

}

總結

以上是生活随笔為你收集整理的虚拟机玩转缓存服务器,Nginx服务器中浏览器本地缓存和虚拟机的相关设置的全部內容,希望文章能夠幫你解決所遇到的問題。

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