Wordpress - Expires Headers in .htaccess won't work

1.1k Views Asked by At

According to www.gtmetrix.com 2 components are without a far-expiration date: enter image description here

I added at the end of my .htaccess

ExpiresActive on
ExpiresDefault                                      "access plus 1 month"
                                                    "access plus 1 month"

# Web fonts

# Collection
ExpiresByType font/collection                       "access plus 1 month"

# Embedded OpenType (EOT)
ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
ExpiresByType font/eot                              "access plus 1 month"

# OpenType
ExpiresByType font/opentype                         "access plus 1 month"
ExpiresByType font/otf                              "access plus 1 month"

# TrueType
ExpiresByType application/x-font-ttf                "access plus 1 month"
ExpiresByType font/ttf                              "access plus 1 month"

# Web Open Font Format (WOFF) 1.0
ExpiresByType application/font-woff                 "access plus 1 month"
ExpiresByType application/x-font-woff               "access plus 1 month"
ExpiresByType font/woff                             "access plus 1 month"

# Web Open Font Format (WOFF) 2.0
ExpiresByType application/font-woff2                "access plus 1 month"
ExpiresByType font/woff2                            "access plus 1 month"


# Other

ExpiresByType text/x-cross-domain-policy            "access plus 1 week"

and nothing happens. What can I do to set for these two componets expiration dates?

2

There are 2 best solutions below

0
On BEST ANSWER

optimize speed.

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On 
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
0
On

The scripts are from third party, not from you server. You have no control to add the expires headers.