Otu esi eme ka & hazie mkpakọ Gzip na Nginx

Akụkụ nke ọrụ weebụsaịtị ọ bụla bụ ijide n'aka na ndị ọbịa nwere ike ịlele saịtị ahụ ngwa ngwa o kwere mee. N'agbanyeghị nke ahụ, otu n'ime ihe kachasị akpata mbelata bụ ịkwanye akụrụngwa dabere na nha nwere ike imetụta weebụsaịtị na-enweghị GZIP enyere aka na webụsaịtị yiri ya.

NGINX bụ ezigbo sava weebụ, wuru maka ọsọ ọsọ, dị fechaa ijikwa ọtụtụ njikọ, ọ na-abịa na nkwado GZIP, mana nke a nwere ike ịbụ mma agha ihu abụọ ka iji GZIP na-abawanye ojiji CPU. Dabere na ihe nkesa gị na akụrụngwa ya, ọ nwere ike inwe mmetụta dị iche na-enyere ya aka na-enweghị nkwalite.

Ya mere mmasị na isiokwu dị anya? N'ime nkuzi anyị, ị ga-amụta ntọala GZIP bụ isi.

GZIP kachasị - Ntọala ntọala

Nke mbụ, gaa na ndekọ nginx gị wee mepee ya nginx.conf faịlụ.

sudo nano /etc/nginx/nginx.conf

Na-esote, detuo ntọala ndị a kachasị mma maka mmeghe maka mkpakọ.

Nke a dị mma maka sava ndị na-enweghị ọtụtụ ihe onwunwe iji chekwaa. Ọ bụ isi ma na-arụ ọrụ.

## enables GZIP compression ##
 gzip on; 

 ## compression level (1-9) ##
 ## 4 is a good compromise between CPU usage and file size. ##
 gzip_comp_level 4;

 ## minimum file size limit in bytes, to low can have negative impact. ##
 gzip_min_length 1000;

 ## compress data for clients connecting via proxies ##
 gzip_proxied any;

 ## disables GZIP compression for ancient browsers that don't support it. ##
 gzip_disable "msie6";

 ## compress outputs labeled with the following MIME-types. ##
 ## do not add text/html as this is enabled by default. ##
 gzip_types
     application/json
     application/javascript
     application/xml
     text/css
     text/javascript
     text/plain
     text/xml;

Ị nwere ike ịnọ na-eche tupu anyị eleba anya na ntọlite ​​​​kawanye elu ihe ụfọdụ okwu pụtara.


Advertisement


Nkọwa GZIP

Ọkwa mkpakọ - gzip_comp_level #;

Enwere ike ịtọ gzip_comp_level n'etiti 0 ruo 9. Nke kachasị elu ọkwa mkpakọ, a na-etinye mkpakọ dị elu. Mgbe ọkwa mkpakọ dị elu dị ka max ga-abụ 9, mgbe ahụ achọrọ CPU ọzọ. Ọ bụrụ na ihe nkesa gị na-agbasi mbọ ike na ojiji CPU, a na-atụ aro ka ị nọrọ n'etiti etiti ka azụmaahịa maka ịbawanye ntọala a pere mpe, na ị gaghị ahụ ihe dị iche na nsonaazụ ya.

Ogologo mkpakọ kacha nta - gzip_min_length #;

Nginx na-eji mkpakọ mgbe ogologo nzaghachi dị ịrịba ama karịa 1000 bytes nke enweghị ike ịgbanwe. Ị nwere ike ịtọ nke a ala karịa 1000 bytes; Otú ọ dị, maka obere faịlụ, oge a na-ewe iji mpikota onu faịlụ ndị a dị mkpa karịa oge echekwara na mbufe. Ọzọkwa, ị ga na-emechi iji CPU na-enweghị isi, na n'ọnọdụ ụfọdụ, ị nwere ike ịbawanye nha faịlụ, dị ka faịlụ static dị ka ihe oyiyi nke na-ekwesịghị ịgụnye.

Mkpakọ dị iche iche nkụnye eji isi mee – gzip_proxied #;

Ntuziaka a na-agwa ndị proxies ka ha chekwaa ma ụdị akụrụngwa ahụ oge niile yana gzipped. Nginx ga-agbakwunye nkụnye eji isi mee naanị mgbe ejiri mkpakọ, dabere na ntọala gzip_min_length.

Ụdị Mime mkpakọ

Ụdị mime dị n'ime gị /yourlocation/nginx/mime.types bụ ụdị ọdịnaya edepụtara na Nginx gị nke GZIP nwere ike mpikota onu ma ọ bụrụ na edepụtara ya. Anyị depụtara naanị ndị bụ isi; Otú ọ dị, ị nwere ike ịpịkọta ọtụtụ akụkụ ndị ọzọ. Cheta ka ị ghara gzip static faịlụ dị ka onyonyo, n'ihi na ọ ga-enwe mmetụta ọjọọ.

Naanị faịlụ ọnụọgụ abụọ enwere ike iji onyonyo chịkọta bụ "Onyinye/svg+xml"

Nginx kachasị elu na ntọala GZIP

N'okpuru ebe a, anyị ga-egosi ihe atụ nke nhazi ọkwa dị elu karị, enwere ike ịme ọtụtụ ihe, yana ị kwesịrị ịnwale ihe na-arụ ọrụ nke ọma na ihe nkesa gị n'okpuru ibu dị ndụ.

Cheta, gị nginx.conf dị na folda nginx.

sudo nano /etc/nginx/nginx.conf
## enables GZIP compression ##
 gzip on; 

 ## compression level (1-9) ##
 ## 4 is a good compromise between CPU usage and file size. ##
 gzip_comp_level 6;

 ## minimum file size limit in bytes, to low can have negative impact. ##
 gzip_min_length 1000;

 ## compress data for clients connecting via proxies. ##
 gzip_proxied any;

 ## disables GZIP compression for ancient browsers that don't support it. ##
 gzip_disable "msie6";

 ## compress outputs labeled with the following MIME-types. ##
 ## do not add text/html as this is enabled by default. ##

 gzip_types
     application/atom+xml
     application/geo+json
     application/javascript
     application/x-javascript
     application/json
     application/ld+json
     application/manifest+json
     application/rdf+xml
     application/rss+xml
     application/xhtml+xml
     application/xml
     font/eot
     font/otf
     font/ttf
     image/svg+xml
     text/css
     text/javascript
     text/plain
     text/xml;

Maka nnwale emesia, webụsaịtị ole na ole dịka Onyinye maka ọsọ ọsọ na SiteCheckerPro nwere ike ime ule ịntanetị. Nke a nwere ike ịbụ ụzọ kachasị mfe iji gwa ka ihe nkesa gị si arụ ọrụ n'okpuru ibu sitere na isi mmalite.

Okwu na Nkwubi okwu

GZIP bụ otu n'ime ụzọ kachasị dị irè iji kwalite webụsaịtị gị tupu ngwanrọ mbelata enwee ike ịgbaka ma mebie weebụsaịtị n'oge nhazi. GZIP agaghị emetụta webụsaịtị gị n'ụzọ na-adịghị mma ọ gwụla ma ị debere ọnụego mkpakọ na CPU nke ukwuu ma ọ bụ ogologo opekempe dị ala ebe ọ na-akpakọ faịlụ ndị na-adịghị mkpa.

Ọtụtụ ọnụ ọgụgụ na-agwa gị ka ị na-agba ọsọ bụ ihe dị ịrịba ama maka ọkwa SEO, na ngwọta a dị mfe nwere ike ịbụ ihe dị iche na ịnweta okporo ụzọ na ogologo oge.

Idenye aha
Gwa nke
0 Comments
Inline nzaghachi
Lee echiche niile
0
Ga-ahụ n'anya gị echiche, biko okwu.x