简体   繁体   中英

GZIP Compression Not Working For Wordpress Site

I'm implementing a website in wordpress. When I test my site on google page speed, It's looking horrible. I'm getting some compression issues.

    Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yK/r/XVnmkWxbmyb.js could save 152KiB (74% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yz/r/7emJbLsMYck.js could save 123.6KiB (72% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yY/r/MYnSaHkqljr.js could save 121.7KiB (70% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yh/r/Sst4Eu6wCBO.js could save 69.3KiB (70% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/y6/r/luizkbRWOQS.js could save 24.2KiB (67% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yI/r/oDzewPwhRt1.js could save 21.7KiB (74% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yP/r/gcdIMTVPpBq.css could save 17.3KiB (77% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yf/r/nrh6Sehx1Iz.css could save 15.4KiB (73% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yV/r/1pZAFn_KQPn.css could save 14.2KiB (74% reduction).
Compressing http://www.advancebestmaid.com.sg/ could save 12.7KiB (72% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/ya/r/acNHHHLf-Ph.js could save 11.3KiB (69% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yR/r/qGNhIQHDeK2.js could save 9.3KiB (63% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yr/r/V2fXuYrZ-4H.css could save 3.6KiB (71% reduction).
Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yY/r/Uj-Y3GNRxq1.js could save 3.3KiB (59% reduction).

I already checked with my server to make sure that, GZIP is enabled. And I'm using Yoast SEO plugin to enable HTTP (gzip) compression on my site.

This is my .htaccess code:

    <IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

I cannot understand why the compression not working. Please help me guys.

URL: mysite

add these lines too

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_include mime ^text/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
mod_gzip_item_exclude mime ^image/.* 
mod_gzip_item_include handler ^cgi-script$
</ifModule>

You cannot compress external (loaded from external domains) javascripts or css. Almost all those files are loaded from https://static.xx.fbcdn.net/ . You have to complain about it to Facebook. It is their domain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM