Cache policy for my images
-
Hi,
I am trying to fix the cache policy error in Google Pagespeed (Serve static assets with an efficient cache policy).
I know that I can’t fix all of them, but some are jpeg and png images:I read that I can edit my .htaccess but I am not very confident + I have different .htaccess files on my FTP.
Is there any other solution to fix this error for my images ?
Thanks in advance for you help,
Alex
-
Hi,
Please provide the report number
you can get it in toolbox -> report -> click “send to LiteSpeed”
Best regards,
Done!
Hi,
yes, but please provide me the generated string
Best regards,
Sorry : SESQEXLF
Hi,
Please contact your hosting provider
something weird on the header
the LSCWP part is fine with this code in .htaccess
ExpiresByType xx/xxx A31557600
but their server-level setting probaby override some setting
Best regards,
Hi,
They don’t really seems to know what to do.
Do you know if I can change something myself in the .htaccess ?
Regards
Hi,
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=31557600, public" </filesMatch>
try add this to your .htaccess
Best regards
Hi,
Thanks.
I tried to add it in the .htaccess, just after:# END LBCWpFastestCache
It didn’t work
and I also tried to replace:
<IfModule mod_headers.c>
Header set Expires “max-age=2592000, public”
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>by :
<IfModule mod_headers.c>
Header set Expires “max-age=31557600, public”
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>Didn’t work either
Should I put this in another place ?
no , remove this block
<IfModule mod_headers.c>
Header set Expires “max-age=31557600, public”
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>then add
<filesMatch “.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$”>
Header set Cache-Control “max-age=31557600, public”
</filesMatch>HI,
Thanks for your time. I tried, then cleared my cache (plugin and browser) but it didn’t change.
Here is my .htaccess. I don’t use WP fastest anymore so I don’t understand why there is some WP fastest cache info in it..
# BEGIN WebP Express
# Les directives (lignes) entre ‘BEGIN WebP Express’ et ‘END WebP Express’ sont
# généré dynamiquement, et ne doivent uniquement être modifiées via les filtres WordPress.
# Toute modification des directives entre ces marqueurs sera outrepassée.
# Plugin is deactivated
# END WebP Express<FilesMatch “index\.(html|htm)$”>
AddDefaultCharset UTF-8
<ifModule mod_headers.c>
FileETag None
Header unset ETag
Header set Cache-Control “max-age=0, no-cache, no-store, must-revalidate”
Header set Pragma “no-cache”
Header set Expires “Mon, 29 Oct 1923 20:30:00 GMT”
</ifModule>
</FilesMatch>
# END WpFastestCache
# BEGIN GzipWpFastestCache
<IfModule mod_deflate.c>
AddType x-font/woff .woff
AddType x-font/ttf .ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/opentype font/ttf font/eot font/otf
</IfModule>
# END GzipWpFastestCache
# BEGIN LBCWpFastestCache
<FilesMatch “\.(webm|ogg|mp4|ico|pdf|flv|jpg|jpeg|png|gif|webp|js|css|swf|x-html|css|xml|js|woff|woff2|ttf|svg|eot)(\.gz)?$”>
<IfModule mod_expires.c>
AddType application/font-woff2 .woff2
ExpiresActive On
ExpiresDefault A0
ExpiresByType video/webm A2592000
ExpiresByType video/ogg A2592000
ExpiresByType video/mp4 A2592000
ExpiresByType image/webp A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType image/svg+xml A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType application/font-woff2 A2592000
</IfModule>
<IfModule mod_headers.c>
Header set Expires “max-age=2592000, public”
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>
</FilesMatch>
# END LBCWpFastestCache
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule># BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch “\.(ico|jpe?g|png|gif|swf)$”>
Header set Cache-Control “public”
</filesMatch>
<filesMatch “\.(css)$”>
Header set Cache-Control “public”
</filesMatch>
<filesMatch “\.(js)$”>
Header set Cache-Control “private”
</filesMatch>
<filesMatch “\.(x?html?|php)$”>
Header set Cache-Control “private, must-revalidate”
</filesMatch>
</ifModule>Hi,
remove all these rules , only keep the wordpress rule and LSCWP rule
then enable browser cache in LSCWP setting , make sure you see dozens of
ExpiresByType xx/xxx A31557600
lines in itthen add
<filesMatch ".(ico|pdf|flv|jpg|jpeg|webp|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=31557600, public" </filesMatch>
into your .htaccess
then go to LSCWP -> purge all
after purge , check the HTTP response header on your images , you should see
cache-control: max-age=31557600, public
if not , then means something in your server is overriding it which I can not be any further help , that requires your hosting provider to assist
Best regards,
Hi,
Thanks. It doesn’t work. But I wonder if it is not due to the fact that I don’t use the right .htaccess file. I have ” .htaccess files :
I have one under public_html
Another under public_html > wp-content
and the last one under public_html > wp-content > themesThe second and the third have the same code in it (the one I sent) but the first one (under public_html) is very different:
# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* – [E=Cache-Control:no-autoflush]
RewriteRule \.object-cache\.ini – [F,L]### marker CACHE RESOURCE start ###
RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php – [E=cache-control:max-age=3600]
### marker CACHE RESOURCE end ###### marker FAVICON start ###
RewriteRule favicon\.ico$ – [E=cache-control:max-age=86400]
### marker FAVICON end ###### marker DROPQS start ###
CacheKeyModify -qs:fbclid
CacheKeyModify -qs:gclid
CacheKeyModify -qs:utm*
CacheKeyModify -qs:_ga
### marker DROPQS end ###</IfModule>
## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
### marker BROWSER CACHE start ###
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A31557600
ExpiresByType image/x-icon A31557600
ExpiresByType image/vnd.microsoft.icon A31557600
ExpiresByType image/svg+xml A31557600ExpiresByType image/jpg A31557600
ExpiresByType image/jpeg A31557600
ExpiresByType image/png A31557600
ExpiresByType image/gif A31557600
ExpiresByType image/webp A31557600ExpiresByType video/ogg A31557600
ExpiresByType audio/ogg A31557600
ExpiresByType video/mp4 A31557600
ExpiresByType video/webm A31557600ExpiresByType text/css A31557600
ExpiresByType text/javascript A31557600
ExpiresByType application/javascript A31557600
ExpiresByType application/x-javascript A31557600ExpiresByType application/x-font-ttf A31557600
ExpiresByType application/x-font-woff A31557600
ExpiresByType application/font-woff A31557600
ExpiresByType application/font-woff2 A31557600
ExpiresByType application/vnd.ms-fontobject A31557600
ExpiresByType font/ttf A31557600
ExpiresByType font/woff A31557600
ExpiresByType font/woff2 A31557600</IfModule>
### marker BROWSER CACHE end ##### LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
# END NON_LSCACHE
# BEGIN WordPress
# Les directives (lignes) entre ? BEGIN WordPress ? et ? END WordPress ? sont générées
# dynamiquement, et doivent être modifiées uniquement via les filtres WordPress.
# Toute modification des directives situées entre ces marqueurs sera surchargée.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule># END WordPress
Maybe it creates a conflict and I should delete the second and the third.
Hi,
what is the content on /wp-content/.htaccess ?
if it’s same block beforemenitoned , back it up and remove it
sub-dir’s htaccess will override the parent dir htaccess
Best regards,
Hi,
It didn’t work.
Never mind, thanks a lot for your help and your time.Regards,
Hi,
try this as last resort
create file /wp-content/uploads/.htaccess
put
<filesMatch ".(ico|pdf|flv|jpg|jpeg|webp|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=31557600, public" </filesMatch>
into it
- The topic ‘Cache policy for my images’ is closed to new replies.