On some older Web Hosting instances, Gzip compression is not enabled by default. In other cases, compression may not be configured for certain file types on your instance. As a result, you might find that Gzip compression fails to apply to your site, even after you configure it. This topic shows you how to fix this issue.
Problem description
You have configured Gzip compression for a Web Hosting instance that runs a Linux operating system, but it is not being applied to your website.
Causes
-
Compression is not enabled by default on some older Web Hosting instances.
-
Compression is not configured for certain file types.
Solution
-
Check if Gzip compression is enabled on your Web Hosting instance.
-
Open your website in a browser.
-
Press F12 to open the browser's developer tools.
-
Click the Network tab.
-
Click a file under the Name column. In the Response Headers section on the right, check if the value of the Content-Encoding header is gzip.
-
Yes: Gzip compression is enabled. Proceed to the next step.
-
No: Gzip compression is not enabled. Please submit a ticket.
-
-
-
Use an FTP client to connect to your Linux-based Web Hosting instance.
For more information, see Use FileZilla to manage files.
-
In the
/htdocsdirectory of your Linux-based Web Hosting instance, locate the.htaccessfile.NoteThe .htaccess file is hidden by default. To display hidden files in your FTP client, see Display hidden files in the file list of an FTP client. To modify the
.htaccessfile, download it from the Remote site panel, edit it, and then upload it back. -
In the
.htaccessfile, use the DEFLATE algorithm to compress specific file types.The following sample code compresses common file types, such as plain text, HTML, XML, and CSS files:
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/x-httpd-php AddOutputFilterByType DEFLATE application/x-httpd-fastphp AddOutputFilterByType DEFLATE image/svg+xml