How to clear Google mod_pagespeed Cache on your Server

Google released an open source Apache module to simplify the optimization of your content. The module, mod_pagespeed, will do all sorts of magic like minify your JS/CSS and optimize images, and a handful of other optimizations that seem (from limited testing) to improve your servers performance considerably. If you haven’t installed mod_pagespeed, see Install Google Mod_Pagespeed on CentOS with DirectAdmin or Install Google Mod_Pagespeed on RHEL, CentOS and Fedora.

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 especially true when making small changes.

Luckily deleting the cache is quite simple. You need root access for this.

The first, find your “cahe” folder. Conventional, “cache” folder located in “var” folder (/var/cache). SSH to your server. Then type or paste in the following commands:

cd /var/cache

If you see mod_pagespeed displayed, mod_pagespeed cache is stored here.

Clear Google mod_pagespeed Cache

Clear Google mod_pagespeed Cache

Go to “mod_pagespeed” folder, you will see “http,3A” folder. “http,3A” folder is stored place all caches of domains. “Cache folders” is named as “,2Fyourdomain” (for example: , So, use the following command to delete cache folder:

rm -rf ,2Fyourdomain

I recommended you use WinSCP to to transfer files securely on your server.

Delete Google Mod Pagespeed Cache Folder

Delete Google Mod Pagespeed Cache Folder

If you want to clear all caches of mod_pagespeed, delete “mod_pagespeed” folder and recreate it and change ownership this folder to apache:

rm -rf /var/cache/mod_pagespeed
mkdir /var/cache/mod_pagespeed
chown apache:apache /var/cache/mod_pagespeed

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:

service httpd restart

You should be able to restart Apache from your servers GUI control panel, such as Cpanel.

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
Somesh Rao
6 years ago

THanks for the info.

One error in the article is that you can clear the cache in memory without restarting the server.

Just do

sudo touch /var/cache/mod_pagespeed/cache.flush

The docs are here

4 years ago
Reply to  Somesh Rao

The cache.flush thing doesn’t work. The cache never clears.

4 years ago

Google pagespeed is not recommended, when you get many visitors it can overload the server load.

3 years ago

Thanks for the info. Found after the “touch” method didn’t work permanently, file kept coming back. Easiest to just delete and recreate, dirs, besides there seemed to be a bunch junk around best to clean and easy to do.

Would love your thoughts, please comment.x