一次HTTP請求會遇到哪些緩存

1,HTTP請求生命週期

The primary phases of the request lifecycle are:php

Redirect
Immediately begins startTime.
If a redirect is happening, redirectStart begins as well.
If a redirect is occurring at the end of this phase then redirectEnd will be taken.
App Cache
If it’s application cache fulfilling the request, a fetchStart time will be taken.
DNS
domainLookupStart time is taken at the beginning of the DNS request.
domainLookupEnd time is taken at the end of the DNS request.
TCP
connectStart is taken when initially connecting to the server.
If TLS or SSL are in use then secureConnectionStart will start when the handshake begins for securing the connection.
connectEnd is taken when the connection to the server is complete.
Request
requestStart is taken once the request for a resource has been sent to the server.
Response
responseStart is the time when the server initially responds to the request.
responseEnd is the time when the request ends and the data is retrieved.nginx

 

2,遇到的緩存

2.1, 應用的本地緩存,如 local storage, session_storage, cookie等;web

2.2, DNS查找時的DNS緩存;緩存

2.3, 請求到了服務器端,通過web server, 以nginx爲例,有nginx的緩存;服務器

2.4, 當nginx將請求交給項目進程時,進程管理工具cgi, fast-cgi, fpm(fast process manager),例如php-fpm,在執行PHP文件時,會進行語法分析,詞法分析,語義分析,將文件轉換成操做碼opcode,若是開啓了opcache,則直接使用opcache;cookie

2.5, 請求到了項目時,框架自帶的cache,如 Laravel的路由緩存, route cache等;session

2.6, 框架處理請求,內部的NoSQL緩存;app

2.7, DB操做,以MySQL默認的InnoDB存儲引擎爲例,它會對查詢語句作緩存,因此咱們常常會遇到,兩條相同的SQL語句,第一次執行時稍微有點慢,第二次就比第一次快,是由於第一次執行完了後,InnoDB將查詢結果緩存起來了。框架

相關文章
相關標籤/搜索