If your WordPress website feels slow, one of the easiest fixes is enabling Gzip compression. This method reduces the size of your website files (HTML, CSS, JavaScript, etc.) before sending them to visitors. Smaller files load faster, which means better user experience, higher SEO ranking, and improved Core Web Vitals.
In this guide, I’ll show you step by step how to enable Gzip compression in WordPress using different methods.
Gzip is a popular compression technology that reduces the size of web pages and resources on the server before sending them to browsers.
For example:
This is why tools like Google PageSpeed Insights and GTmetrix often recommend “Enable Gzip Compression.”
You can enable Gzip in different ways depending on your hosting setup.
.htaccess
(Apache Servers)If your website uses Apache, just edit the .htaccess file in the root directory of WordPress and add this code:
AddOutputFilterByType DEFLATE text/html text/css text/javascript AddOutputFilterByType DEFLATE application/javascript application/x-javascript AddOutputFilterByType DEFLATE application/json application/xml AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml AddOutputFilterByType DEFLATE application/font-woff application/font-woff2 AddOutputFilterByType DEFLATE image/svg+xml
Save changes and clear cache.
nginx.conf
(Nginx Servers)If your hosting uses Nginx, open your nginx.conf
file and add:
gzip on; gzip_comp_level 6; gzip_min_length 256; gzip_proxied any; gzip_vary on; gzip_types text/plain text/css application/json application/javascript application/xml text/xml text/javascript application/font-woff application/font-woff2 image/svg+xml;
Restart Nginx after saving.
If you don’t want to edit server files, use a caching plugin:
Just install, activate, and enable “Gzip compression” in settings.
If your hosting has cPanel, follow these steps:
After enabling, you should test if compression works.
Use free tools like:
content-encoding: gzip
If you see gzip
or br
(Brotli), compression is active.
Enabling Gzip compression in WordPress is a quick win for website speed and SEO. Whether you do it through .htaccess
, Nginx, cPanel, or a plugin, the result will be a lighter, faster, and more user-friendly website.
If you want even better performance, you can also use Brotli compression (newer and more efficient than Gzip).
Next, I recommend checking out my guide on Website Tracking Tools to monitor your site performance.