How to clear Google mod_pagespeed Cache

At Shine Servers Hosting all our servers have Google’s mod_pagespeed installed. We have seen good website load time decreases, with server load only increasing noticeably when creating the cache from scratch.

The only irritating thing for developers is that sometimes mod_pagespeed does not recognise that you have updated an image or other files and keeps serving up the old version. This is espically true when making small changes.

Luckily deleting the cache is quite simple. You need root access for this. First SSH to your server. Then type or paste in the following commands;

sudo mv /var/mod_pagespeed/cache /var/mod_pagespeed/cache.del
sudo rm -rf  /var/mod_pagespeed/cache.del
sudo mkdir /var/mod_pagespeed/cache
sudo chown nobody:nobody /var/mod_pagespeed/*

The first line moves your cache directory the second deletes the now moved directory. This code assumes that you are using the default cache directory, if you have changed the directory remember to change the code! The third line recreates the cache directory and the fourth sets the correct permissions on the folder.

This will clear all cache on disk there is also cache stored in memory and the only way to remove this is to restart Apache. You should be able to restart Apache from your servers GUI control panel, such as Cpanel.

I will be posting more blog entries about google mod_pagespeed including how to customise it and fix problems it may cause on your website.