CDN and Leverage Browser Caching

Hi All,

I’ve installed WP Fastest Cache with Cloudflare instructions few days ago. However, when I’m doing a GTmetrix test, it shows me the following:

  • List item

Leverage browser caching for the following cacheable resources:

What’s the problem? Please advise.

  1. Anything not on your domain can not be fixed by you, such as Google resources.
  2. Sometimes GTMetrix doesn’t recognize Cloudflare as a CDN. That’s their mistake.

The only links you posted aren’t in your domain, so the above is all I can suggest.

What about the expiration date? During the settings I’ve chosen 6 months. But here it says no expiration?

What about this links:

You can host your analytics script locally,to reduce your external HTTP requests to Google from 2 down to 1, and have full control over the caching of the file. ( Google set a low 2 hour cache time on their asset). Be aware that this technique not supported officially by Google.

As @sdayman said, GTMetrix doesn’t recognize CloudFlare as a CDN…So don’t need to worry about this one.

The Leverage Browser Caching warning is referring to your browser cache. The warning appears because the third-party servers, doesn’t have the correct HTTP cache headers implemented, or the cache time is too short.
You can check your headers in Chrome DevTools network panel or simply be re-running your WordPress site through WebPageTest.org (for more better and clear results).

1 Like

Thanks for answering. Regarding the Leverage Browser Caching, in my .htaccess file it says the following

AddType application/font-woff2 .woff2 AddType application/x-font-opentype .otf ExpiresActive On ExpiresDefault A0 ExpiresByType video/webm A10368000 ExpiresByType video/ogg A10368000 ExpiresByType video/mp4 A10368000 ExpiresByType image/webp A10368000 ExpiresByType image/gif A10368000 ExpiresByType image/png A10368000 ExpiresByType image/jpg A10368000 ExpiresByType image/jpeg A10368000 ExpiresByType image/ico A10368000 ExpiresByType image/svg+xml A10368000 ExpiresByType text/css A10368000 ExpiresByType text/javascript A10368000 ExpiresByType application/javascript A10368000 ExpiresByType application/x-javascript A10368000 ExpiresByType application/font-woff2 A10368000 ExpiresByType application/x-font-opentype A10368000 ExpiresByType application/x-font-truetype A10368000

Shouldn’t it be changed to a specific expiration timing?

Most probably, you are using a caching plugin, that wrote into your .htaccess file.
You should check your plugin settings - server settings and change it accordingly.

I do use a caching pluging (WP Fastest Cache). During the settings I’ve chosen as advised - 6 months. But .htaccess file shows no expiration

This is most probably an issue on your web app side, and not CloudFlare’s side.
Check if this plugin has the rights to write into your wp-content/plugins directory and the root folder, to be able to modify your .htaccess file.
You can find a more WordPress related support into WordPress.org forums.

I see. What if I manually change the .htaccess file something like

ExpiresActive On

Images

ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType image/webp “access plus 1 year”
ExpiresByType image/svg+xml “access plus 1 year”
ExpiresByType image/x-icon “access plus 1 year”

Video

ExpiresByType video/mp4 “access plus 1 year”
ExpiresByType video/mpeg “access plus 1 year”

CSS, JavaScript

ExpiresByType text/css “access plus 1 month”
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”

Others

ExpiresByType application/pdf “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”

Should it be okay?

Give it a shot, doesn’t look bad to me, but definitely if you Google it you will find hundred methods.

Also make sure to know what type of server you are using, for example NginX server doesn’t support .htaccess, you will have to edit your nginx config to achieve that.
On the other hand, if you run on Apache, the things are different.
If you are not managing your server, you should ask help from your hosting provider

I have access to my htaccess file through Yoast SEO plugin. My server is using apache I believe

Theres nothing we can do here from our side.
Connect through FTP (or SFTP) to access the.htaccess or use a plugin like File Manager.

Your Web Host that already knows your server set up, should know the best approach depend their settings etc.

1 Like

Thanks a lot for your assistance. Appreciate!

1 Like