How to enable GZIP compression on a droplet with Openlitespeed WordPress installation?

Posted September 10, 2020 1.9k views
WordPressCachingOpenLiteSpeed WordPress 1-Click

I am a noob! So, I need some help. I installed Openlitespeed WordPress from the Marketplace on a droplet with Ubuntu.
I never had any idea that LSCache doesn’t have the option of GZIP compression. I want to enable it without using an additional plugin. Can anyone guide me?
As I said, I am a noob. Some help with a simple explanation or a step-by-step guide will be really helpful.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
4 answers

Hi @shivaranjanibaidya,

Gzip compression is enabled by default if I’m not mistaken. Having said that it’s usually hidden by the PHP settings. You’ll need to edit the following line in your PHP.ini file

;zlib.output_compression_level = -1

You’ll need to enable it like so

zlib.output_compression_level = 1

After you do, you can restart apache/nginx and everything should be working.

As for the Gzip compression, as far as I know, OpenLiteSpeed supports .htaccess so you should be able to add the following in your .htaccess file for your website :

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/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"

<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 mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*


  • Hello KFSys,

    Thank you for your help. I have two more questions. Do I need to do both? That is, edit the php.ini and add .htaccess rule?

    If I do need to edit php.ini file, where do I find it, and how do I access it?

    Thank you in advance.

    Shiva Ranjani

Hi @shivaranjanibaidya ,

I just want to provide some information here for OpenLiteSpeed gzip question.

The OpenLiteSpeed comes with both Gzip/Brotli compression enabled, so you don’t need to do anything. That’s why LSCache Plugin has no such feature.

FYI, Browser cache is also enabled by default on server level.


  • Eric, please pardon my ignorance on this subject.

    The question here is that if Gzip is enabled by default, then why is PageSpeed Insights is saying “Serve static assets with an efficient cache policy?”

    Also, why is the Pingdom test saying “Compress components with gzip,” and “Add Expires headers?”

    I am just unable to figure it out. Some help from you can help me understand the problems and fix them.

    Best Regards,
    Shiva Ranjani

@eleu, The url is Can you please go through it once? Not all resources. I guess a few of them.

edited by MattIPv4

HI @shivaranjanibaidya ,

You can ignore the compression alert from Pingdom since they don’t support brotli from the first beginning. If you test on GTMetrix, all shows score A (98%). I also didn’t see any issue on Pagespeed Insights.

Currently your static files are served by cloudflare, so if you see “Serve static assets” again, you might want to look into your CDN settings.