- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How To enable GZIP Compression in PHP?
GZIP Compression is a simple, effective way to save bandwidth and speed up PHP application. The mechanism runs behind the GZIP compression is described below −
The browser/client request for a file to the server.
The server sends a .zip file to the browser (index.html.zip) rather than plain old index.html in response, due to which the download time and bandwidth decreases.
After the execution of the above step, the browser downloads the zipped file, extracts it, and then shows it to the user. This loads the webpage very quickly.
In the Apache server, we have to Add the following to .htaccess file to enable GZIP compression.
In PHP files we can enable GZIP compression.
<?php if (substr_count($_SERVER[‘HTTP_ACCEPT_ENCODING’], ‘gzip’)) ob_start(“ob_gzhandler”); else ob_start(); ?>
- Enable MySQL Compression
- Compression compatible with gzip in Python (zlib)
- How to configure nginx with gzip module for compression on centos 7
- PHP compression Stream Wrappers
- Python Support for gzip files (gzip)
- How can I extract or uncompress gzip file using php?
- How to enable or disable interlace using imageinterlace() function in PHP?
- Difference between Lossy Compression and Lossless Compression
- How to enable Bluetooth in android?
- How to enable wifi in android?
- Program to perform string compression in Python
- Data compression in SAP HANA