Ukulungiswa kwe-OPcache PHP yokuqalisa

Kuba website ezisekelwe WordPress , Joomla okanye Laravel , umzekelo, yaye akukho umsebenzisi-ngqo, uyacebiswa ukuba onke amaphepha kwi cache static HTML kwaye kutsha nje i cache ngesandla (okanye ngokuzenzekelayo) ukuba kukho utshintsho kwi somva. Nangona kunjalo, ukuba iphepha linomxholo onamandla oxhomekeke kwiseshoni kunye neicookies okanye kulwimi nakwindawo, i- OPcache ilungile .


Ixesha elibizwa ngokuba li-boot kuzo zontathu iinkqubo ezikhankanyiweyo zingaphezulu kwe-100 ms ngeseva entsha yeCentOS7 (ene-SSD kunye ne-PHP 7.1). Ngalo lonke ixesha iscript se-PHP senziwa, kufuneka sidityaniswe kwi-bytecode ngexesha lokubaleka. I-OPcache ngoku iphumeza i-cache yale bytecode- ukuba iskripthi esifanayo se-PHP senziwa ngesicelo esilandelayo, akufuneki sibuyekezwe. Emva kokuvula i-OPcache, sibeka useto olulandelayo:

9006cec6c5d3d2498ee26c5bfd91590a

Ixesha lokuphumeza (umndilili ongaphezulu kwe-10 wokubulawa) ngoku lincitshisiwe kakhulu:

IWordPress 4.7.4 U-Joomla 3.7 Ulungelelwaniso 5.4
ngaphandle kwe-OPcache 295 ms 201 ms 110 ms
nge-OPcache 54 ms 59 ms 13 ms
Into 5,5 3,5 8,5

Kuba siseta i-validate_timestamp ukuya ku-0 kwaye ngaxeshanye siphinda siqinisekise_freq ukuya kusuku olunye, i-cache iphantse ayaze yakhiwe ngokuzenzekelayo (siyakwenza oku ngokwenza ngesandla). Nge- hook encinci ye- git , iskripthi se-PHP senziwa ngayo yonke into "yokutsala". Uyenza njani isebenze ihhuku:

a1678610c8b4c7db5997375944183830

a1678610c8b4c7db5997375944183830

Lo msebenzi ulandelayo uncedayo ukulinganisa imilinganiselo yekhowudi nganye (okanye lonke ixesha lokuphumeza):

085f4291bbcc4e8a64bbea951ff49ab9

Ukuba ufuna ukufumana ulwazi oluluncedo olufana nenqanaba, imemori esetyenzisiweyo okanye inani eligciniweyo leefayile, usebenzisa lo msebenzi we-PHP:

3f6309d04bc7e48dd909859321b96209

Ukuxhamla kwi-OPcache kwindawo yophuhliso lwasekhaya (engacetyiswayo ngokubanzi), sisebenzisa iqhinga.

I-OPcache iyasebenza kuzo zonke iiseva ezineemodyuli ze-OPcache ezifakiweyo kwaye apho iseti ye-opcache enika amandla ingasetwanga ngokucacileyo. Sishiya sinjalo. Simisela kuphela i-opcache.validate_timestamps = 1 kwi-php.ini. Kwiiprojekthi apho sifuna ukwenza i-OPcache ngokusisigxina, sisebenzisa ezinxulumene neprojekthi kwi .htaccessUmiselo olulandelayo:

1dd64a3f2fe4425b29b1409410fe3fc0

Emva koko siqala kwakhona iserver yewebhu kwaye senze iskripthi esilandelayo:

91fb5289160e410607c9ea89112a575b

Iskripthi siyayicoca i-cache kwaye siyakhe kwakhona ngaxeshanye. Ngoku wabeka i ezinxulumene-mvali wezithuba RunOnSave umyalelo kwi esizithandayo umhleli VSCode:

91fb5289160e410607c9ea89112a575b

Emva