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>