These days, the Industry Standard expiration time for CSS, JS and similar type files is 1 month. For any type of image it is 1 year. As you cannot set or change expires headers for files or content you are loading from a different site, if Google wants to complain about its own settings then so be it.
The following is just a suggestion but you may be pleasantly suprized at how will it works; faster load page time on revisits and improved site security.
Delete the following within: /includes/.htaccess
Code:
<IfModule mod_headers.c>
Header unset Pragma
FileETag None
Header unset ETag
#Header set Cache-Control "no-transform"
<FilesMatch "(?i).*\.(ico|jpe?g|gif|webp|png|otf|swf|flv|ttf|woff|eot|svg)$">
Header set Cache-control "max-age=864000, public, must-revalidate"
Header unset Last-Modified
</FilesMatch>
<FilesMatch "(?i).*\.(html|htm|xml|txt|xsl)$">
Header set Cache-control "max-age=7200, must-revalidate"
</FilesMatch>
</IfModule>
Add the following stating at the very top of: public_html/.htaccess
Code:
#############################
## General Settings
Options +SymLinksIfOwnerMatch -FollowSymlinks -Indexes
RewriteEngine ON
# Define the default Character Set for Browsers
AddDefaultCharset utf-8
#############################
## Header Settings
<IfModule mod_headers.c>
# Set the default language of your site
Header set Content-Language "en-CA"
# Ensure the most current site files are being provided
Header set Cache-Control "proxy-revalidate, stale-while-revalidate=86400, stale-if-error=259200"
# Prevents seeing information not needed to see
Header unset X-Powered-By
# Protection against PHP or Javascript code placed within images and other misinterpretations of your resources.
Header set X-Content-Type-Options "nosniff"
# Protection against Clickjacking
Header set X-Frame-Options "SameOrigin"
# Protection against XSS (Cross-Site Scripting)
Header set X-XSS-Protection "1; mode=block"
# Protection against abuse of Adobe Flash / Silverlight / PDF files
Header set X-Permitted-Cross-Domain-Policies "Master-Only"
</IfModule>
#############################
## EXPIRES CACHING
# Note: You cannot set expires headers for files or content you are loading from a different site.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 day"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/x-javascript "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"
# TrueType
ExpiresByType application/x-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"
</IfModule>
If any of the above code is duplicated further down in your .htaccess file, remove it.
Legend
## General Settings - optional but good practice to place at the very top
## Header Settings - optional but does provide very good, basic site protection
## EXPIRES CACHING - will solve most if not all, caching problems
You can verify if the above makes any difference by using
https://gtmetrix.com/ before changes and after. Make sure to save the URL of the first result for comparison with the second result.
Bookmarks