復制代碼如下:#註意proxy_temp_path和proxy_cache_path指定的路徑必須在同壹個分區proxy _ temp _ path/data/proxy _ temp _ dir;#設置Web緩存區的名稱為cache_one,內存緩存空間的大小為MB。自動清除多日未訪問的內容。硬盤緩存空間大小為GB proxy _ cache _ path/data/proxy _ cache _ dir levels =:keys _ zone = cache _ one:m inactive = d max _ size = g;服務器{ listenserver _ name yourdomain索引索引索引;root/data/htdocs/;Location/{#如果後端服務器返回執行超時等錯誤,自動將請求轉發給上遊負載均衡池中的另壹臺服務器實現故障轉移proxy _ next _ upstream _ _ error time out invalid _ header;proxy _ cache cache _ one#為不同的HTTP狀態碼設置不同的緩存時間proxy _ cache _ valid h;Web緩存的鍵值Nginx由域名URI參數組成,緩存內容根據鍵值進行哈希處理,存儲在二級緩存目錄proxy _ cache _ Key $ host $ uri $ is _ args $ args;proxy _ set _ header Host $ host為$remote_addr轉發的proxy _ set _ header X;proxy _ pass//後端_服務器;到期d;} #用於清除緩存假設壹個URL是可以通過訪問location ~ /purge(/ *)清除的緩存{#設置只允許指定的IP或IP段清除URL緩存allow;允許/;否定壹切;proxy _ cache _ purge cache _ one $ host $ $ is _ args $ args;} #擴展名以php jsp cgi結尾的動態應用不緩存位置~ * (php|jsp|cgi)?$ { proxy _ set _ header Host $ host為$remote_addr轉發的proxy _ set _ header X;proxy _ pass//後端_服務器;} access _ log off}} fastcgi_cache緩存設置
復制代碼如下:#定義文件夾fastcgi _ cache _ path/TT/cache levels =:keys _ zone = name:inactive = dmax _ size = g;#定義緩存不同的url請求fastcgi _ cache _ key " $ scheme $ request _ method $ host $ uri $ arg _ filename $ arg _ x $ arg _ y ";服務器{ listenserver_name示例;location/{ root/;index index index php} location ~(| PHP)$ { root/;fastcgi _ pass:;fastcgi_cache名稱;fastcgi _ cache _ valid h;fastcgi _ cache _ min _ usesfastcgi_cache_use_stale錯誤超時invalid _ header _fastcgi _ index index phpfastcgi _ param SCRIPT _ FILENAME/scripts $ fastcgi _ SCRIPT _ name;包括fastcgi conf#在設置緩存的過程中,發現無法獲取cookies。經過調查,需要定義這句話fastcgi _ pass _ header Set Cookie} log _ format access $ remote _ addr $ remote _ user[$ time _ local]" $ request " $ status $ body _ bytes _ sent " $ _ referer " " $ _ user _ agent " $ _ x _ forwarded _ for;access_log / }壹般來說,nginx的proxy_cache和fastcgi_cache的緩存配置差不多。memcache緩存在討論memcache緩存之前,我們先來了解壹下mysql的內存緩存。mysql的內存緩存可以在我的cnf中指定大小。內存表和臨時表是不壹樣的,臨時表也是內存最大的。內存需要通過tmp _ table _ size = m來設置,當數據已經檢查了臨時表的最大值後,會自動轉換成磁盤表。此時由於IO操作的需要,性能會大大降低,內存表不會滿,會提示數據滿的錯誤情況。
復制代碼如下:create table test(id int unsigned not null auto _ increment主鍵state char () type char () date char())。engine = memory default charset = utf lishixinzhi/Article/program/PHP/201311/21248