Hi mọi người.
Nén Gzip cho website sẽ giúp cho web của bạn load với tốc độ nhanh hơn rất nhiều lần. Và giảm được khoảng 70% dung lượng của web khi mở bằng trình duyệt.
-
Lợi ích của bật nén Gzip
Nhiều khả năng thích nghi với kết quả tìm kiếm
Giảm bớt yêu cầu về máy chủ của bạn
1000KB sẽ được chuyển thành 100KB
Có nhiều cách nén có thể dùng plugin hoặc .htaccess. Dưới đây là cách dùng với file .htaccess -
Cách thực hiện
Thêm đoạn code sau vào file .htaccess trong thư mục gốc ngang hàng với wp-admin nhé
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950## EXPIRES CACHING ##ExpiresActive OnExpiresByType image/jpg "access plus 1 month"ExpiresByType image/jpeg "access plus 1 month"ExpiresByType image/gif "access plus 1 month"ExpiresByType image/png "access plus 1 month"ExpiresByType text/css "access plus 1 month"ExpiresByType application/pdf "access plus 1 month"ExpiresByType text/x-javascript "access plus 1 month"ExpiresByType application/javascript "access plus 1 month"ExpiresByType application/x-javascript "access plus 1 month"ExpiresByType application/x-shockwave-flash "access plus 1 month"ExpiresByType image/x-icon "access plus 1 year"ExpiresDefault "access plus 2 days"## EXPIRES CACHING ### 1 Month for all your static assetsHeader set Cache-Control "max-age=2592000, public"# 1 DAYS for rss feeds and robotsHeader set Cache-Control "max-age=86400, public, must-revalidate"# 4 HOURS for your real articles filesHeader set Cache-Control "max-age=14400, must-revalidate"# compress text, html, javascript, css, xml:AddOutputFilterByType DEFLATE text/plainAddOutputFilterByType DEFLATE text/htmlAddOutputFilterByType DEFLATE text/xmlAddOutputFilterByType DEFLATE text/cssAddOutputFilterByType DEFLATE application/xmlAddOutputFilterByType DEFLATE application/xhtml+xmlAddOutputFilterByType DEFLATE application/rss+xmlAddOutputFilterByType DEFLATE application/javascriptAddOutputFilterByType DEFLATE application/x-javascriptAddType x-font/otf .otfAddType x-font/ttf .ttfAddType x-font/eot .eotAddType x-font/woff .woffAddType image/x-icon .icoAddType image/png .png
Công cụ giúp các bạn kiểm tra đã bật nén Gzip chưa
link
link
Chúc các bạn thành công ^^
Nguồn: levantoan[.]com










