Enable GZIP compression on DirectAdmin hosting

GZIP compression is one of the easiest and most effective ways to speed up your website. It compresses HTML, CSS, JavaScript, and XML files before sending them to the visitor's browser, typically reducing file sizes by 60–80%. The result is faster page loads — especially noticeable on mobile devices and slow connections.

How GZIP Compression Works

When a browser requests a file, it sends the header Accept-Encoding: gzip. If the server supports GZIP, it compresses the file before sending, and the browser decompresses it automatically. This entire process is transparent to the user.

On shared hosting using Apache (the standard for DirectAdmin), GZIP is enabled through mod_deflate or mod_gzip directives in your .htaccess file.

Real-world impact: A typical 200KB HTML file compresses to ~50KB. A 100KB CSS framework compresses to ~20KB — pages load 3–5x faster on slow connections.

How to Enable GZIP via .htaccess on DirectAdmin

Method 1: Using mod_deflate (Recommended)

Add the following code to your .htaccess file in your website root (public_html):

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>

Method 2: Using mod_gzip (Older Servers)

<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 handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>

How to Edit .htaccess via DirectAdmin File Manager

  1. Log into DirectAdmin → File Manager
  2. Navigate to public_html
  3. Click .htaccess and select Edit
  4. Append the GZIP code at the end of the file
  5. Click Save

Which File Types to Compress (and Which to Skip)

File Type Compress? Reason
HTML, CSS, JS✅ Yes60–80% size reduction
XML, JSON, SVG✅ YesText-based, compresses well
JPEG, PNG, WebP❌ NoAlready compressed, minimal gain
PDF, ZIP, MP4❌ NoAlready compressed, may get larger

How to Test If GZIP Is Working

Browser Developer Tools

  1. Press F12 to open DevTools → Network tab
  2. Reload the page
  3. Click the main HTML file → Headers tab
  4. Look for Content-Encoding: gzip in Response Headers

Online Testing Tools

Impact on Lighthouse Score and SEO

Google PageSpeed Insights and Lighthouse include an "Enable text compression" audit. Without GZIP, your Performance score takes a hit. Enabling it typically improves the score by 5–15 points. Since page speed is a direct Google ranking factor, enabling GZIP has an indirect positive effect on your SEO.

WordPress users: Plugins like WP Rocket, W3 Total Cache, and LiteSpeed Cache include a GZIP toggle — but setting it via .htaccess ensures it works regardless of plugin conflicts.

GZIP vs Brotli Compression — Which Should You Use?

GZIP has been the standard compression algorithm for over 20 years. Brotli, developed by Google, compresses text files approximately 15–25% better than GZIP — but it comes with more requirements:

Feature GZIP (mod_deflate) Brotli (mod_brotli)
Compression ratio Good (60–80%) Better (70–85%)
Shared hosting support ✅ Nearly universal ⚠️ Apache 2.4.26+ required
Configurable via .htaccess ✅ Easy Requires mod_brotli to be loaded
Browser support ✅ 100% ✅ Chrome, Firefox, Edge, Safari

For DirectAdmin shared hosting, GZIP via mod_deflate is the safe and effective choice. Brotli is not yet widely available on shared hosting because it requires mod_brotli to be enabled at the server level — something individual users cannot do through .htaccess alone.

How GZIP Reduces Bandwidth Costs

For higher-traffic websites, enabling GZIP does more than improve speed — it directly reduces bandwidth consumption, which affects hosting costs and user experience:

Bandwidth estimate: A typical website with 1,000 visitors/day and 500KB average page size can save approximately 350MB/day (70% reduction) — around 10GB per month without any infrastructure changes.

Combining GZIP with Browser Caching

GZIP and browser caching are complementary — not alternatives. Both should be enabled together for maximum performance gains:

Add browser caching to your .htaccess alongside GZIP:

# Browser cache for static assets
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType image/jpeg "access plus 3 months"
  ExpiresByType image/png "access plus 3 months"
  ExpiresByType image/webp "access plus 3 months"
</IfModule>

Combining GZIP, browser caching, and HTTP/2 (supported on AsiaGB Hosting) is the most effective performance stack for static websites on shared hosting — no CDN required to reach high Lighthouse scores.

Troubleshooting GZIP Issues

GZIP and Core Web Vitals — Impact on LCP

Core Web Vitals have been a Google ranking factor since 2021. LCP (Largest Contentful Paint) is the metric most directly affected by enabling GZIP, particularly when your HTML file or render-blocking CSS is large.

GZIP is the first optimization to implement before anything else in a web performance audit — it is free, requires no code changes, and produces immediate measurable results on every page load for every visitor.

GZIP for WordPress on DirectAdmin

WordPress sites generate a large number of CSS and JavaScript files, making GZIP especially impactful. Beyond .htaccess configuration, several WordPress-specific approaches are worth knowing:

WordPress Plugins That Include GZIP Support

Regardless of which plugin you use, always keep the .htaccess GZIP directive in place. If a plugin is deactivated or causes a conflict, the .htaccess fallback ensures compression continues working without depending on WordPress at all.

Need Hosting That Supports Full GZIP?

AsiaGB Hosting supports mod_deflate, HTTP/2, and full .htaccess customization — speed up your website from day one.

Get AsiaGB Hosting

View all cheap Thailand web hosting plans →