Table of Contents

PageSpeed Insights not seeing the Gzip compression

Why PageSpeed Insights Misses Your Gzip Compression It is a common frustration when you meticulously configure your server for performance, implement Gzip...

2026-08-10

Why PageSpeed Insights Misses Your Gzip Compression

It is a common frustration when you meticulously configure your server for performance, implement Gzip compression via .htaccess, and yet tools like Google PageSpeed Insights (PSI) report that the compression is not being utilized or recognized. As a senior developer, I can tell you that this discrepancy usually stems from a misalignment between how the web server processes the request and how automated testing tools crawl and measure the delivered content.

The fact that your external gzip test tool confirms compression is active suggests the server is capable of compressing files, but something is preventing PageSpeed Insights from seeing or properly measuring the effect across all assets.

Understanding Server-Side vs. Client-Side Compression

Gzip compression works by instructing the web server (in this case, Apache) to compress the file before sending it to the client. When PSI runs its crawl, it relies on fetching the raw content and analyzing the resulting HTTP response headers. If the server is configured correctly, the headers should indicate that the response body has been compressed (e.g., Content-Encoding: gzip).

In environments like CodeIgniter running on Apache, the .htaccess directives (AddOutputFilterByType DEFLATE...) are designed to handle this compression effectively for static files. However, there are several layers where failure can occur:

  1. Server Module Status: The underlying module responsible for compression (like mod_deflate) must be properly enabled and loaded by the Apache installation. If this is disabled at the core server level, .htaccess rules will be ignored.
  2. Request Scope: Not all requests are handled by these directives. Certain dynamic routes or specific content types might bypass the file-based filtering if the application framework (like CodeIgniter) handles output generation in a way that conflicts with standard Apache pipeline processing.
  3. Caching and Crawling Behavior: Automated tools sometimes cache results or follow paths differently than a direct browser request, leading to discrepancies.

Troubleshooting Steps for CI/Apache Setups

Since you are working within a CodeIgniter environment, let's focus on ensuring the setup is robust beyond just the .htaccess file.

1. Verify Apache Configuration

Before diving deeper into the application code, ensure the server itself is correctly configured to handle compression globally. Check your main Apache configuration files (httpd.conf or relevant virtual host settings) to confirm that mod_deflate is loaded and enabled. If you are using a managed hosting environment, this step might be restricted, requiring you to contact support. Good performance practices, much like those followed in building scalable applications on platforms such as Laravel Company, start with solid infrastructure setup.

2. Inspect HTTP Headers Directly

Use your browser's Developer Tools (Network tab) to inspect the actual response headers when loading a page. Look specifically for the Content-Encoding header. If Gzip is working, you should see something like Content-Encoding: gzip. If this header is missing or incorrect, it confirms that the server is not sending the compressed stream as expected.

3. Consider Application-Level Optimization

If file-level compression via .htaccess remains inconsistent with automated tools, consider moving optimization closer to the application layer. For dynamic content generated by CodeIgniter, optimizing PHP execution time and minimizing database queries often yields larger gains than pure file compression. Frameworks like Laravel advocate for performance deep within the code structure, ensuring that object instantiation and query handling are as efficient as possible before any data is sent to the client.

4. Alternative Compression Methods (The Modern Approach)

While .htaccess works well for static files, modern deployments often leverage Content Delivery Networks (CDNs) or reverse proxies (like Nginx) for compression. CDNs handle the caching and delivery of compressed assets globally, often providing superior performance metrics tracked by tools like PSI. If you are running a more complex setup, transitioning to a CDN layer can simplify header management and improve overall PageSpeed scores significantly.

Stefan

Stefan

SEO engineer and Laravel developer. Building tools to help Laravel applications rank higher in search results.

Share this article

Back to Blog