Her phone call woke me up this morning before the sunrise. She wanted to see me at her place now. Now? How? It was still a bit dark outside. She also said breakfast is ready for me. Very weird! She lives nearby and it takes a few minutes to arrive there. So, I started to walk.
I asked her where is my breakfast. She smiled and she gave me her laptop to fix her website. Oh no! I felt like running away. She said she didn’t sleep last night and she was trying to enable compression on her website to make it fast. And? She googled everywhere and found some codes on some websites and she added them to her .htaccess file and now her website’s totally down and it didn’t enable compression at all. I asked her which type of compression did she want exactly? She said she wanted Gzip compression for her website.
Alright, after blaming me for nothing, she went to the kitchen to make breakfast for us. I knew there was no breakfast ready. What to do now?
First of all, I needed to know which type of server that she was using. I found it was a Litespeed server and then I opened her .htaccess file. Really, she tried all the codes possible to enable Gzip! Sometimes, it is a bit hard and tricky if you want to enable Gzip on Litespeed servers, doesn’t work well on Apache as well.
I then removed all those codes that she added to enable Gzip compression. and I decided to add a single line at the very top of her .htaccess file, so I added that and I saved the file. Did it work? I checked the website with the “inspect element/inspect” on Chrome browser and in the “network” section, it was indicating, “gzip” was enabled. Alright, it is done. I also noticed pages were loading amazingly fast. I screamed at her, may I go home now? I saw her fixing the table for our breakfast and it will take a few minutes more. So, meanwhile, I would tell you a few more things.
First of all, let’s see how users normally activate Gzip compression on Apache or on Litespeed and what are the issues that create.
They normally add the following things to the .htaccess file to enable Gzip. But it is not any stable option, sometimes gzip is enabled and sometimes it is found disabled. And especially on Lightspeed servers, these codes often have no effect. But, I want Gzip is enabled always without any issues.
These are the codes below which users normally use to activate Gzip compression. I would strongly disagree with these things or the similar things given below. These codes below sometimes create strange browser issues and it creates a bottlenecked feeling while browsing since scrolling and navigation are not smooth at all.
She is calling me to have breakfast. But, before I go I would tell you the line that I added to her .htaccess file to enable Gzip. It was simply this line given below,
php_value output_handler ob_gzhandler
Note: This simple line above enables “Gzip” on Apache and Litespeed both. If you want a stable “gzip” compression, you want gzip is enabled always and you want smooth performance as well along with the stability, please add this single line at the top of your .htaccess file.
Alright, I am going to eat. All the best.