Leverage Browser Caching for images

Posted in: Newspaper
Post count: 26

Hi,
I have set the Leverage Browser Caching as recommended in https://forum.tagdiv.com/how-to-make-the-site-faster/
However, all the .jpg and .png files such as header and mobile logos, images, etc shows:
.jpg (expiration not specified)
.png (expiration not specified)
How can I fix it?

Thanks

Post count: 623

Hello @BigHead_s

If you are using CloudFlare, make sure you have set Browser Cache Expiration to minimum 8 days.

Post count: 26

No, I don’t use any CloudFlare

Post count: 26

Here is the link to my website: goo.gl/nT2Ztr
Its Leverage browser caching score in gtmetrix is 10! All because of images.
How can it be fixed?

Thanks!

Post count: 623

Use following code instead:

# BEGIN Caching
<ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch "\\.(js)$">
Header set Cache-Control "max-age=216000, private"
</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=216000, public, must-revalidate"
</filesMatch>
<filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=1, private, must-revalidate"
</filesMatch>
</ifModule>
# END Caching

Post count: 26

Tried it, but the same problem occurs. What do you suggest to do now?

Post count: 623

Kindly purge all the site cache and try.

Post count: 26

Already did it several times in WP Super Cache.

Post count: 26

Here is how it looks on gtmetrix: goo.gl/3q7Puk

Post count: 623

Hey you using Nginx server. And you using apache tips
Use expiry header for Nginx

This may help you
https://www.nginx.com/blog/9-tips-for-improving-wordpress-performance-with-nginx/

Post count: 26

I tried expiry headers from my host https://www.siteground.com/kb/leverage-browser-caching/
but the same problem still exists. Also, I did delete the cache.
Here is the content of my .htaccess

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTPS} !on [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R=301,L]
#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mysite.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg “access 1 year”
ExpiresByType image/jpeg “access 1 year”
ExpiresByType image/gif “access 1 year”
ExpiresByType image/png “access 1 year”
ExpiresByType text/css “access 1 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType application/javascript “access 1 month”
ExpiresByType application/x-javascript “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType image/x-icon “access 1 year”
ExpiresDefault “access 2 days”
</IfModule>
## EXPIRES CACHING ##

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

AddHandler application/x-httpd-php70 .php .php5 .php4 .php3

RewriteEngine on
RewriteBase /
RewriteRule ^naturopathic/(.*) https://www.mysite.com/naturopathy/$1 [R=301,L]
RewriteRule ^physical-therapist/(.*) https://www.mysite.com/physical-therapy/$1 [R=301,L]

RewriteEngine on
Redirect 301 /physical-therapist https://www.mysite.com/physical-therapy
Redirect 301 /naturopathic https://www.mysite.com/naturopathy

Post count: 9544

Not really theme related. You probably need to contact your hosting provider, as those settings are based on your server, and local site and nothing to do with WordPress or the TagDiv theme. Ideally, they should be able to tell you the correct settings.

Also note you cannot control time to live for browser caching of images hosted elsewhere, such as loaded off FB, ad networks, content loaded from another site, etc. Cache control headers will only help with locally hosted content on your server alone.

(( I don’t work here. ))

  • This reply was modified 9 years by simchris.
Post count: 26

Thanks Amit & Chris, the hosting company could solve some of the problems.

Viewing 13 posts - 1 through 13 (of 13 total)
The forum ‘Newspaper’ is closed to new topics and replies.