Mobile app version of vmapp.org
Login or Join
Welton855

: Browser cache persistently expires for images in mod_pagespeed cache Recently installed Google's plugin mod_pagespeed and I want to use it exclusively to address image optimization. So far the result

@Welton855

Posted in: #Apache2 #GooglePagespeed

Recently installed Google's plugin mod_pagespeed and I want to use it exclusively to address image optimization.

So far the result frim Pagespeed insights has been hit or miss. Half the time it does fine, the other half it complains that I should "Leverage browser caching for the following cacheable resources." - with a long list of nearly every image on my home page cached at the 5 minute default.

Now I've read that this can sometimes happen if the module hasn't completely finished rendering the cached version and that it will serve a temporary image with a short cache in the interim. But I can't understand why that would be the case since the images have not changed and they are the same images it only just 10 minutes ago said were fine.

So as far as I can see:


the images are there in the cache and being served without issue
the image files have not changed so the cache should remain valid


I am running Apache 2.4.18 and mod_pagespeed 1.11.33.5-0. The config file pagespeed.conf is configured with the following two lines toward the bottom before the <Location> block:

ModPagespeedRewriteLevel PassThrough
ModPagespeedEnableFilters rewrite_images,extend_cache_images


Can anyone suggest an explanation for what looks to be a persistently expiring cache?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Welton855

1 Comments

Sorted by latest first Latest Oldest Best

 

@Sarah324

I have found that mod_pagespeed serves images and other resources with a cache expiration of 5 minutes if they are not available in its cache directory (yet). Also, after restarting the Apache webserver it takes a while until mod_pagespeed regains its maximum efficiency.

It may help to delete and recreate the cache directory:

sudo mv /var/cache/mod_pagespeed /var/cache/mod_pagespeed.del
sudo rm -rf /var/cache/mod_pagespeed.del/
sudo mkdir /var/cache/mod_pagespeed
sudo chown www-data:root /var/cache/mod_pagespeed/
sudo service apache2 restart


To determine the current size of mod_pagespeed's cache directory:

du -hs /var/cache/mod_pagespeed/


To increase the size of the disk cache from 100 MB (default) to 10 GB in mod_pagespeed's configuration file /etc/apache2/mods-enabled/pagespeed.conf:

ModPagespeedFileCacheSizeKb 10240000

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme