How To Easily Clear mod_pagespeed Cache

How To Easily Clear mod_pagespeed Cache

Recently, I ran into an issue with CSS changes not being reflected on the homepage. After countless hours of thinking to myself “Why is updating CSS such a hassle right now? Such a simple task and I can’t even figure this out? I am losing my touch”. After clearing any CDN cache, clearing the CMS cache, my own personal cache, and just about any other cache I could think of, I concluded that this had to be a mod_pagespeed issue. Clearing the mod_pagespeed cache had not occurred to me until I turned it off all together and noticed all the changes were then reflecting onto the site. Clearing said cache is actually quite simple, and I’ll show you how to do this below.

To run these commands you will need to be logged in with a user who has root privileges with an SSH client such as PuTTy.

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/*

To describe what is happening here; the first line moves the mod_pagespeed cache directory while the second line will delete the moved directory. Please take notice that these commands areĀ assuming that you’re using the default cache directory, and if for some reason you have changed the default directory, please remember that you must alter these lines to fit your directory structure! As for the third line, it will recreate the cache directory for you while the fourth line then sets the permissions for said folder.

Remember to restart Apache after these commands are ran. You can do this via your cPanel (or whichever GUI you may use) or you may do this straight from your SSH client. If you would just like do do this from your SSH client, take a look at our quick reference guide on how to restart Apache for each Linux distribution.

Published by using 310 words.