0

My System:

  • CentOS 8.5
  • Apache with ModPagespeed module
  • WordPress
  • "W3 Total Cache" Plugin
  • "CDN Enabler" Plugin to use AWS Cloudfront CDN

I'm using W3 Total Cache WordPress plugin and my .htaccess file has the mod_expires section but the "Add Expires headers" section in the Pingdom Speed Test is always Zero.

I've added the following code under the Virtual Host in the httpd.conf but still no differences, I'm using Cloudflare and I've purged all cache and stopped DNS Proxied but nothing changes.

--- httpd.conf - file ---

<Directory /home/DOMAIN/public_html/site_1>
    # Allow Using .htaccess
    AllowOverride Fileinfo Options
    
    <IfModule pagespeed_module>
        ModPagespeed On

        # ---- Old Code Before ChatGPT Help ----
        #ModPagespeedEnableFilters combine_css,combine_javascript
        #AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html


        # ---- My Last Try with ChatGPT help ----
        ModPagespeedEnableFilters inline_css,inline_javascript
        ModPagespeedEnableFilters collapse_whitespace,remove_comments
        ModPagespeedEnableFilters insert_dns_prefetch
        ModPagespeedEnableFilters lazyload_images
        ModPagespeedEnableFilters local_storage_cache
        ModPagespeedEnableFilters extend_cache

        ModPagespeedRewriteLevel PassThrough

        # Disable caching HTML files
        ModPagespeedDisableFilters rewrite_style_attributes
        ModPagespeedDisableFilters rewrite_style_attributes_with_url
        ModPagespeedDisableFilters prioritize_critical_css

        # Disable caching dynamic content
        ModPagespeedDisableFilters defer_javascript
        ModPagespeedDisableFilters inline_import_to_link
        ModPagespeedDisableFilters inline_google_font_css
        ModPagespeedDisableFilters rewrite_javascript_external

    </IfModule>
    
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/jpeg "access plus 1 week"
        ExpiresByType image/png "access plus 1 week"
    </IfModule>
    
    
    <IfModule mod_deflate.c>
        SetOutputFilter DEFLATE
        # AddOutputFilterByType DEFLATE text/html text/plain text/xml ...
        # Add additional MIME types you want to compress

        # Compress everything except images and PDFs
        SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|pdf)$ no-gzip dont-vary

        # Compress certain file types based on MIME types
        <IfModule mod_filter.c>
            AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript application/json application/rss+xml application/xml image/svg+xml
            # Add additional MIME types you want to compress
        </IfModule>
    </IfModule>
</Directory>

.htaccess file

        <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType text/css A31536000
        ExpiresByType text/x-component A31536000
        ExpiresByType application/x-javascript A31536000
        ExpiresByType application/javascript A31536000
        ExpiresByType text/javascript A31536000
        ExpiresByType text/x-js A31536000
        ExpiresByType text/html A3600
        ExpiresByType text/richtext A3600
        . . . . . .
        . . . . . . 
    </IfModule>
Hady Shaltout
  • 606
  • 1
  • 9
  • 22
  • Is module mod_expires.c loaded? You can increase the LogLevel to get a LOT of extra logs of what is going on. – Nic3500 May 25 '23 at 00:52
  • @Nic3500 My "/etc/httpd/conf.modules.d/00-base.conf" LoadModule expires_module modules/mod_expires.so – Hady Shaltout May 25 '23 at 01:21
  • Look at https://stackoverflow.com/questions/5531994/specifing-expiration-date-for-static-files-caches, your configuration seems ok. I wonder if there is a mix up with Wordpress cache module. You could try deactivating PHP and Wordpress to see if at least straight Apache does the job. Then add components to find which conflicts. – Nic3500 May 25 '23 at 14:35
  • @Nic3500 They're talking modules disabled but by running command "httpd -M" I received "pagespeed_module (shared), expires_module (shared), etc." but in "phpinfo" page, I have this line "extension_dir /usr/lib64/php/modules /usr/lib64/php/modules" – Hady Shaltout May 25 '23 at 17:36

0 Answers0